Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source control release process #112

Merged
merged 7 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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:<br/>
target/linux/x64/**/*.tar.gz,target/linux/x64/**/*.sha256.txt,target/linux/x64/**/*.json,target/linux/x64/**/*.sig<br/>
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()
}
}
}
}
}
}
11 changes: 10 additions & 1 deletion sbin/Release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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"
Expand All @@ -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