From 32fc5b01f98f0215c68f7214a34a89d1f612913b Mon Sep 17 00:00:00 2001 From: Stephen Lane-Walsh Date: Wed, 1 May 2024 13:45:39 -0400 Subject: [PATCH] Build: Fix off-by-one versions produced by Jenkins This fixes the bug where `--os=bootstrap` wasn't receiving the version from `--version=x.y.z` However, confusingly, this also changes the Jenkinsfile to not use that feature, and instead use `git tag` in order to embed the proper git information as well as the proper version information The `--os=bootstrap` and `--version` fix is still included just so that it doesn't break if someone else tries to use it --- Jenkinsfile | 14 ++++++++++---- deploy/platform/bootstrap/bootstrap_build.sh | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 770cd0ed66..b640ed376e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,6 +41,7 @@ if (BRANCH_NAME == "stable") { } def new_version = '0.0.0'; +def new_tag = null; def release_file_list = []; @@ -107,6 +108,8 @@ pipeline { if (new_version == '0.0.0') { error "Failed to calculate new version" } + + new_tag = "${BRANCH_NAME}_release-" + new_version.replaceAll("\\.", "-") echo "Calculated new version to be ${new_version}" } @@ -123,10 +126,14 @@ pipeline { ws("${WORKSPACE}/${OS}") { stage("${OS} Clone") { checkout scm; + + if (new_tag) { + sh "git tag ${new_tag}" + } } stage("${OS} Bootstrap") { - sh "./deploy/build.sh --os=bootstrap --branch=${BRANCH_NAME} --version=${new_version}" + sh "./deploy/build.sh --os=bootstrap --branch=${BRANCH_NAME}" if (OS.endsWith("armhf")) { sh "docker run --rm --privileged multiarch/qemu-user-static:register --reset" @@ -222,8 +229,7 @@ pipeline { stage("Publish to GitHub") { ws("${WORKSPACE}/publish") { - def tag = "${BRANCH_NAME}_release-" + new_version.replaceAll("\\.", "-") - echo "Creating GitHub Release and Tag for ${tag}" + echo "Creating GitHub Release and Tag for ${new_tag}" withCredentials([ usernamePassword( credentialsId: 'MDSplusJenkins', @@ -233,7 +239,7 @@ pipeline { // TODO: Protect against spaces in filenames def release_file_list_arg = release_file_list.join(" ") - sh "./deploy/create_github_release.py --tag ${tag} --api-token \$GITHUB_ACCESS_TOKEN ${release_file_list_arg}" + sh "./deploy/create_github_release.py --tag ${new_tag} --api-token \$GITHUB_ACCESS_TOKEN ${release_file_list_arg}" } } diff --git a/deploy/platform/bootstrap/bootstrap_build.sh b/deploy/platform/bootstrap/bootstrap_build.sh index 89b6989494..a8ef7d840c 100755 --- a/deploy/platform/bootstrap/bootstrap_build.sh +++ b/deploy/platform/bootstrap/bootstrap_build.sh @@ -14,5 +14,6 @@ trap cleanup EXIT INT docker run -t -a stdout -a stderr --cidfile=$cid \ -u $(id -u):$(id -g) --privileged \ -e "HOME=/tmp" \ + -e "RELEASE_VERSION" \ -v "${SRCDIR}:${DOCKER_SRCDIR}" \ ${DOCKERIMAGE} "${DOCKER_SRCDIR}/bootstrap"