Skip to content

Commit

Permalink
Switching to multi-JDK image, enriching build manifest with desired J…
Browse files Browse the repository at this point in the history
…DK version

Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Oct 20, 2021
1 parent 6bef043 commit 4632a62
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 11 deletions.
42 changes: 32 additions & 10 deletions jenkins/opensearch/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ pipeline {
}
}
}
stage('detect JDK version to build') {
steps {
script {
manifest = readYaml(file: "manifests/$INPUT_MANIFEST")

jdk = "${manifest.build.jdk}"
// If the 'jdk' key is not present, it is populated with "null" string
if (jdk == null || jdk == "null") {
// If JDK is not set, use 14
jdk = "14"
}

echo "Using JDK version: " + jdk
}
}
}
stage('build') {
parallel {
stage('build-snapshots') {
Expand All @@ -30,19 +46,21 @@ pipeline {
agent {
docker {
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdk14-node10.24.1-cypress6.9.1-20211005'
image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211019'
// Unlike freestyle docker, pipeline docker does not login to the container and run commands
// It use executes which does not source the docker container internal ENV VAR
args '-e JAVA_HOME=/usr/lib/jvm/adoptopenjdk-14-hotspot'
args '-e JAVA_HOME=$JAVA' + jdk + '_HOME'
alwaysPull true
}
}
steps {
script {
git url: 'https://github.com/opensearch-project/opensearch-build.git', branch: 'main'
sh "./build.sh manifests/$INPUT_MANIFEST --snapshot"
withCredentials([usernamePassword(credentialsId: 'Sonatype', usernameVariable: 'SONATYPE_USERNAME', passwordVariable: 'SONATYPE_PASSWORD')]) {
sh('$WORKSPACE/publish/publish-snapshot.sh $WORKSPACE/artifacts/$ARTIFACT_PATH/maven')
withEnv(['JAVA_HOME=$JAVA' + jdk + '_HOME']) {
git url: 'https://github.com/opensearch-project/opensearch-build.git', branch: 'main'
sh "./build.sh manifests/$INPUT_MANIFEST --snapshot"
withCredentials([usernamePassword(credentialsId: 'Sonatype', usernameVariable: 'SONATYPE_USERNAME', passwordVariable: 'SONATYPE_PASSWORD')]) {
sh('$WORKSPACE/publish/publish-snapshot.sh $WORKSPACE/artifacts/$ARTIFACT_PATH/maven')
}
}
}
}
Expand All @@ -56,7 +74,7 @@ pipeline {
agent {
docker {
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdk14-node10.24.1-cypress6.9.1-20211005'
image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211019'
// Unlike freestyle docker, pipeline docker does not login to the container and run commands
// It use executes which does not source the docker container internal ENV VAR
args '-e JAVA_HOME=/usr/lib/jvm/adoptopenjdk-14-hotspot'
Expand All @@ -65,7 +83,9 @@ pipeline {
}
steps {
script {
build()
withEnv(['JAVA_HOME=$JAVA' + jdk + '_HOME']) {
build()
}
}
}
post() {
Expand All @@ -78,7 +98,7 @@ pipeline {
agent {
docker {
label 'Jenkins-Agent-al2-arm64-c6g4xlarge-Docker-Host'
image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdk14-node10.24.1-cypress6.9.1-20211005'
image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211019'
// Unlike freestyle docker, pipeline docker does not login to the container and run commands
// It use executes which does not source the docker container internal ENV VAR
args '-e JAVA_HOME=/usr/lib/jvm/adoptopenjdk-14-hotspot'
Expand All @@ -87,7 +107,9 @@ pipeline {
}
steps {
script {
build()
withEnv(['JAVA_HOME=$JAVA' + jdk + '_HOME']) {
build()
}
}
}
post() {
Expand Down
1 change: 1 addition & 0 deletions manifests/1.0.0/opensearch-1.0.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ schema-version: "1.0"
build:
name: OpenSearch
version: "1.0.0"
jdk: "14"
components:
- name: OpenSearch
repository: https://github.com/opensearch-project/OpenSearch.git
Expand Down
1 change: 1 addition & 0 deletions manifests/1.0.1/opensearch-1.0.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ schema-version: "1.0"
build:
name: OpenSearch
version: 1.0.1
jdk: "14"
components:
- name: OpenSearch
repository: https://github.com/opensearch-project/OpenSearch.git
Expand Down
1 change: 1 addition & 0 deletions manifests/1.1.0/opensearch-1.1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ schema-version: "1.0"
build:
name: OpenSearch
version: 1.1.0
jdk: "14"
components:
- name: OpenSearch
repository: https://github.com/opensearch-project/OpenSearch.git
Expand Down
1 change: 1 addition & 0 deletions manifests/1.2.0/opensearch-1.2.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ schema-version: "1.0"
build:
name: OpenSearch
version: 1.2.0
jdk: "14"
components:
- name: OpenSearch
repository: https://github.com/opensearch-project/OpenSearch.git
Expand Down
1 change: 1 addition & 0 deletions manifests/2.0.0/opensearch-2.0.0.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build:
name: OpenSearch
version: 2.0.0
jdk: "11"
components:
- name: OpenSearch
ref: main
Expand Down
4 changes: 3 additions & 1 deletion src/manifests/input_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class InputManifest(Manifest):
"schema": {
"name": {"required": True, "type": "string"},
"version": {"required": True, "type": "string"},
"jdk": {"required": False, "type": "string"},
},
},
"schema-version": {"required": True, "type": "string", "allowed": ["1.0"]},
Expand Down Expand Up @@ -78,9 +79,10 @@ class Build:
def __init__(self, data):
self.name = data["name"]
self.version = data["version"]
self.jdk = data.get("jdk", None)

def __to_dict__(self):
return {"name": self.name, "version": self.version}
return {"name": self.name, "version": self.version, "jdk": self.jdk}

class Component:
def __init__(self, data):
Expand Down

0 comments on commit 4632a62

Please sign in to comment.