diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..195e306 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,72 @@ +#!groovy + +pipeline { + agent { label 'master' } + options { + copyArtifactPermission('*'); + } + parameters { + password(name: 'GITHUB_TOKEN', defaultValue: 'SECRET', description: 'Leave this') + string(name: 'TAG', defaultValue: '', description: 'The GitHub tag of the release, e.g. jdk-12+33') + choice(name: 'VERSION', choices: ['JDK21', 'JDK20', 'JDK19', 'JDK17', 'JDK11', 'JDK8'], description: 'Which JDK Version?') + string(name: 'UPSTREAM_JOB_NAME', defaultValue: '', description: 'The full path to the pipeline / job, e.g. build-scripts/openjdk12-pipeline') + string(name: 'UPSTREAM_JOB_NUMBER', defaultValue: '', description: 'The build number of the pipeline / job you want to release, e.g. 92') + string(name: 'UPSTREAM_JOB_LINK', defaultValue: '', description: 'The build link of the pipeline / job you want to release, e.g. 92') + booleanParam(name: 'RELEASE', defaultValue: false, description: 'Tick this box to actually release the binary to GitHub') + string(name: 'ARTIFACTS_TO_COPY', defaultValue: '**/*.tar.gz,**/*.zip,**/*.sha256.txt,**/*.msi,**/*.pkg,**/*.json,**/*.sig', description: '''For example to only ship linux x64:
+target/linux/x64/**/*.tar.gz,target/linux/x64/**/*.sha256.txt,target/linux/x64/**/*.json,target/linux/x64/**/*.sig
+Or **/*x64_linux*.tar.gz,**/*x64_linux*.sha256.txt,**/*x64_linux*.json,**/*x64_linux*.sig''') + string(name: 'ARTIFACTS_TO_SKIP', defaultValue: '', description: 'For example in most release builds we skip the testimage: *testimage*.') + string(name: 'TIMESTAMP', defaultValue: '', description: 'Optional timestamp to add for nightly builds.') + booleanParam(name: 'DRY_RUN', defaultValue: false, description: 'Tick this box will not release the binary to GitHub') + booleanParam(name: 'UPLOAD_TESTRESULTS_ONLY', defaultValue: false, description: 'Tick this box to actually release the binary to GitHub') + } + stages { + stage('Upload Releases') { + steps { + script { + try { + cleanWs() + // use Jenkins crendential to download JDK if source is from openjdkX-pipline + checkout scm + + def upstreamJobName = params.UPSTREAM_JOB_NAME + def upstreamJobNumber = params.UPSTREAM_JOB_NUMBER + if (params.RELEASE && !params.UPSTREAM_JOB_NAME && !params.UPSTREAM_JOB_NUMBER) { + //JOB_LINK could be specific artifact one or the general one + def upstreamJobLink = params.UPSTREAM_JOB_LINK + if (params.UPSTREAM_JOB_LINK) { + if (params.UPSTREAM_JOB_LINK.contains('/artifact/')) { + upstreamJobLink = upstreamJobLink.substring(0, upstreamJobLink.indexOf('/artifact/')) + } + if (upstreamJobLink.endsWith("/")) { + upstreamJobLink= upstreamJobLink.substring(0, upstreamJobLink.length() - 1) + } + upstreamJobNumber = upstreamJobLink.tokenize('/').last() + upstreamJobName = upstreamJobLink.substring(0, upstreamJobLink.indexOf("${upstreamJobNumber}")) + } else { + echo "Set up UPSTREAM_JOB_LINK or UPSTREAM_JOB_NAME with UPSTREAM_JOB_NUMBER " + currentBuild.result = 'FAILURE' + return + } + + } + step([$class: 'CopyArtifact', + fingerprintArtifacts: true, + flatten: true, + filter: "${params.ARTIFACTS_TO_COPY}", + excludes: "${params.ARTIFACTS_TO_SKIP}", + projectName: "${upstreamJobName}", + selector: [$class: 'SpecificBuildSelector', buildNumber: "${upstreamJobNumber}"]]) + sh 'JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 ./sbin/Release.sh' + } catch (Exception err) { + echo err.getMessage() + currentBuild.result = 'FAILURE' + } finally { + cleanWs() + } + } + } + } + } +} \ No newline at end of file diff --git a/sbin/Release.sh b/sbin/Release.sh index b4f2ac7..9a680ce 100755 --- a/sbin/Release.sh +++ b/sbin/Release.sh @@ -71,7 +71,7 @@ else org="--org \"${GITHUB_ORG}\"" fi -if [ "$UPLOAD_TAPS_ONLY" == "false" ]; then +if [ "$UPLOAD_TESTRESULTS_ONLY" == "false" ]; then # Rename archive files (and their associated files: checksum, metadata, sig) to ensure a consistent timestamp across release for file in OpenJDK* do @@ -136,6 +136,7 @@ if [ "$UPLOAD_TAPS_ONLY" == "false" ]; then # NOTE: If adding something here you may need to change the EXPECTED values in releaseCheck.sh files=$(ls "$PWD"/OpenJDK*{.tar.gz,.sha256.txt,.zip,.pkg,.msi,.json,*.sig} | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g') else + #TODO: enhance to a general file name - update groovy release() - case ~/.*AQAvitTapFiles.*/: "adopt"; break; files=$(ls "$PWD"/AQAvitTapFiles.tar.gz) fi @@ -147,6 +148,9 @@ RELEASE_OPTION="" if [ "$RELEASE" == "true" ]; then description="Official Release of $TAG" RELEASE_OPTION="--release" +else if [ "$UPLOAD_TESTRESULTS_ONLY" == "true" ]; then + echo "Test results are only needed to upload for releases!" + exit 1 else # -beta is a special designation that we must use to indicate non GA (non TCK'd) builds. TAG="${TAG}-beta" @@ -158,4 +162,9 @@ if [ "$DRY_RUN" == "false" ]; then cd adopt-github-release || exit 1 chmod +x gradlew GRADLE_USER_HOME=./gradle-cache ./gradlew --no-daemon run --args="--version \"${VERSION}\" --tag \"${TAG}\" --description \"${description}\" ${server} ${org} $RELEASE_OPTION $files" + # Run releaseCheck.sh to check that the correct number of artifacts are live + if [ -z "$TIMESTAMP" -a "$UPLOAD_TESTRESULTS_ONLY" = "false" ]; then + echo "*** PERFORMING RELEASE CHECK TO SEE IF THERE ARE ANY UNEXPECTED PROBLEMS ***" + ./sbin/releaseCheck.sh ${VERSION#JDK} $TAG VERBOSE + fi fi