From ae8fa3de4426fd600e37c734644f89ccaa9d5715 Mon Sep 17 00:00:00 2001 From: Mark Beierl Date: Thu, 8 Sep 2022 11:56:24 -0400 Subject: [PATCH] Force charm build on merge There is no easy method post-merge to determine what charms need to be rebuilt, so we will rebuild all of them Change-Id: I50436a63cf3f63e32105051df8c571dd2dd6d2dd Signed-off-by: Mark Beierl --- jenkins/ci-pipelines/ci_stage_2.groovy | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy index 1c8911f2..73842e37 100644 --- a/jenkins/ci-pipelines/ci_stage_2.groovy +++ b/jenkins/ci-pipelines/ci_stage_2.groovy @@ -31,6 +31,7 @@ def project_checkout(url_prefix,project,refspec,revision) { def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifactory_server,docker_args="",do_stage_4=false) { println("do_stage_3= ${do_stage_3}") ci_helper = load "devops/jenkins/ci-pipelines/ci_helper.groovy" + def isMergeJob = JOB_NAME.contains('merge') stage('Prepare') { sh 'env' @@ -41,7 +42,7 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa } stage('License Scan') { - if (!JOB_NAME.contains('merge')) { + if (!isMergeJob) { sh "devops/tools/license_scan.sh" } else { @@ -51,7 +52,7 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa stage('Release Note Check') { if (fileExists('devops-stages/stage-releasenote.sh')) { - if (!JOB_NAME.contains('merge')) { + if (!sMergeJob) { sh "devops-stages/stage-releasenote.sh" } else { @@ -109,7 +110,7 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa sh "sudo rm -rf ${WORKSPACE}/stage/ ${WORKSPACE}/parts/ ${WORKSPACE}/prime/" REV="" - if ( !JOB_NAME.contains('merge') ) { + if ( ! isMergeJob ) { REV="/"+"${GERRIT_REFSPEC}".replaceAll('/','-') } channel="latest" @@ -150,7 +151,7 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa def directory = charmPath CHECK_CHANGES = "git diff --name-only origin/$GERRIT_BRANCH -- $directory |wc -l" charmsChanged = sh(returnStdout:true, script: CHECK_CHANGES).trim() - if (charmsChanged != "0") { + if (charmsChanged != "0" || isMergeJob) { println("$directory has changes, rebuilding") parallelSteps[directory] = { @@ -166,7 +167,7 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa try { dir("${directory}") { try { - sh "charmcraft pack --format json --verbosity brief 1> pack.json 2> pack-stderr.log" + sh "charmcraft pack --force --format json --verbosity brief 1> pack.json 2> pack-stderr.log" } catch (Exception e) { sh "cat pack-stderr.log" throw e @@ -182,6 +183,13 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa println("Uploading $resourceName") sh "charmcraft upload --format json --verbosity brief $resourceName 1> upload.json 2> upload-stderr.log" } catch (Exception e) { + def errorMessage = sh( + returnStdout: true, + script: 'cat upload.json | jq -r ".errors[0].message" | grep -v null').trim() + if (errorMessage.contains("already exists")) { + println("No changes, skipping upload") + return 0 + } sh "cat upload-stderr.log" throw e } -- 2.25.1