From: Mark Beierl Date: Thu, 15 Sep 2022 18:12:55 +0000 (-0400) Subject: Adding resource X-Git-Tag: release-v13.0-start~33 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=3b17371ff6f3d5524d127fe8d4967bba80b02840;p=osm%2Fdevops.git Adding resource Turns out we do need to be explicit on image resource revision to use when publishing a charm to a new track/branch Change-Id: Id666eac063e20274f19f70aee4c6d13a3cf6cd3a Signed-off-by: Mark Beierl --- diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy index fa94d4be..e4b63d41 100644 --- a/jenkins/ci-pipelines/ci_stage_2.groovy +++ b/jenkins/ci-pipelines/ci_stage_2.groovy @@ -171,15 +171,14 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa throw e } - def resourceName = sh( + def charmFilename = sh( returnStdout: true, script: 'cat pack.json | jq -r ".charms[0], .bundles[0]" | grep -v null').trim() withCredentials([string(credentialsId: 'Charmstore', variable: 'CHARMCRAFT_AUTH')]) { - commandOutput = sh(returnStdout:true, script: "charmcraft whoami") try { - println("Uploading $resourceName") - sh "charmcraft upload --format json --verbosity brief $resourceName 1> upload.json 2> upload-stderr.log" + println("Uploading $charmFilename") + sh "charmcraft upload --format json --verbosity brief $charmFilename 1> upload.json 2> upload-stderr.log" } catch (Exception e) { def errorMessage = sh( returnStdout: true, @@ -209,7 +208,29 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa def charmName = sh( returnStdout:true, script: "if [ -f bundle.yaml ];then cat bundle.yaml;else cat metadata.yaml;fi|yq -r .name").trim() - sh "charmcraft release ${charmName} --revision=${charmRevision} --channel=${channel}/edge/${charmBranch}" + + def resourceArgument = "" + try { + def resourceName = sh( + returnStdout:true, + script: "cat metadata.yaml | yq '.resources | keys | .[0]'").trim() + + resourceArgument = "--resource $resourceName:1" + + resourceName = sh( + returnStdout:true, + script: "cat metadata.yaml | yq '.resources | keys | .[1]'").trim() + if( resourceName != "null" ) { + resourceArgument += " --resource $resourceName:1" + } + + } catch (Exception discard) { + print("No resource associated with bundle, skipping") + } + + print("resourceArgument = $resourceArgument") + + sh "charmcraft release ${charmName} --revision=${charmRevision} ${resourceArgument} --channel=${channel}/edge/${charmBranch}" } } } finally {