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 <mark.beierl@canonical.com>
diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy
index 44e6ae9..a6dcfa4 100644
--- a/jenkins/ci-pipelines/ci_stage_2.groovy
+++ b/jenkins/ci-pipelines/ci_stage_2.groovy
@@ -201,7 +201,7 @@
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 @@
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()
+ script: "cat metadata.yaml | yq '.resources | keys | .[0]'"
+ ).trim()
if( resourceName != "null" ) {
- resourceArgument += " --resource $resourceName:1"
+ 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:$resourceVers"
+
+ 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) {