X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=jenkins%2Fci-pipelines%2Fci_stage_2.groovy;fp=jenkins%2Fci-pipelines%2Fci_stage_2.groovy;h=e4b63d4155093394061c6e3a71bac30f951e9760;hb=3b17371ff6f3d5524d127fe8d4967bba80b02840;hp=fa94d4bea340f0102b898b7fa05dd47672af6b97;hpb=4510195faffba4e9d7a1459267d585ff218f7060;p=osm%2Fdevops.git 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 {