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,
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 {