From: Mark Beierl Date: Thu, 12 Jan 2023 20:14:58 +0000 (-0500) Subject: Use branch for charms X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F40%2F12840%2F1;p=osm%2Fdevops.git Use branch for charms When merging changes for charms in a development branch (ie: not v10.0, etc), we want to publish it to latest/edge/branch-name so that it can be kept separate from the other branches of development Change-Id: I8f2ec65057d2029d7cda83b9b607a0474a801455 Signed-off-by: Mark Beierl (cherry picked from commit 27da38deb3b184608a6d66ab6bc476506d8d7301) --- diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy index 44e6ae9a..a6dcfa46 100644 --- a/jenkins/ci-pipelines/ci_stage_2.groovy +++ b/jenkins/ci-pipelines/ci_stage_2.groovy @@ -201,7 +201,7 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa def channel="latest" if (BRANCH_NAME.startsWith("v")) { channel=BRANCH_NAME.substring(1) - } else if (BRANCH_NAME!="master") { + } else if (BRANCH_NAME!="master" && JOB_NAME.contains('merge')) { charmBranch=BRANCH_NAME } @@ -213,15 +213,28 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa try { def resourceName = sh( returnStdout:true, - script: "cat metadata.yaml | yq '.resources | keys | .[0]'").trim() + script: "cat metadata.yaml | yq '.resources | keys | .[0]'" + ).trim() + if( resourceName != "null" ) { + sh "charmcraft resource-revisions $charmName $resourceName | head -2 | tail -1 | awk '{print \$1}'" + def resourceVers = sh( + returnStdout:true, + script: "charmcraft resource-revisions $charmName $resourceName | head -2 | tail -1 | awk '{print \$1}'" + ).trim() - resourceArgument = "--resource $resourceName:1" + resourceArgument = "--resource $resourceName:$resourceVers" - resourceName = sh( - returnStdout:true, - script: "cat metadata.yaml | yq '.resources | keys | .[1]'").trim() - if( resourceName != "null" ) { - resourceArgument += " --resource $resourceName:1" + resourceName = sh( + returnStdout:true, + script: "cat metadata.yaml | yq '.resources | keys | .[1]'").trim() + + if( resourceName != "null" ) { + resourceVers = sh( + returnStdout:true, + script: "charmcraft resource-revisions $charmName $resourceName | head -2 | tail -1 | awk '{print \$1}'" + ).trim() + resourceArgument += " --resource $resourceName:$resourceVers" + } } } catch (Exception discard) {