- stage('Snap promotion') {
- withCredentials([string(credentialsId: 'Snapstore', variable: 'SNAPCRAFT_STORE_CREDENTIALS')]) {
- snaps = ['osmclient']
- for (snap in snaps) {
- channel = 'latest/'
- if (BRANCH_NAME.startsWith('v')) {
- channel = BRANCH_NAME.substring(1) + '/'
- } else if (BRANCH_NAME != 'master') {
- channel += '/' + BRANCH_NAME.replaceAll('/', '-')
- }
- track = channel + 'edge\\*'
- edge_rev = sh(returnStdout: true,
- script: "snapcraft revisions $snap | " +
- "grep \"$track\" | tail -1 | awk '{print \$1}'").trim()
- track = channel + 'beta\\*'
- beta_rev = sh(returnStdout: true,
- script: "snapcraft revisions $snap | " +
- "grep \"$track\" | tail -1 | awk '{print \$1}'").trim()
-
- print "Edge: $edge_rev, Beta: $beta_rev"
-
- if (edge_rev != beta_rev) {
- print "Promoting $edge_rev to beta in place of $beta_rev"
- beta_track = channel + 'beta'
- sh "snapcraft release $snap $edge_rev $beta_track"
- }
- }
- }
- } // stage('Snap promotion')
- stage('Charm promotion') {
- charms = [
- 'osm', // bundle
- 'osm-ha', // bundle
- 'osm-grafana',
- 'osm-mariadb',
- 'mongodb-exporter-k8s',
- 'mysqld-exporter-k8s',
- 'osm-lcm',
- 'osm-mon',
- 'osm-nbi',
- 'osm-ng-ui',
- 'osm-pol',
- 'osm-ro',
- 'osm-prometheus',
- 'osm-vca-integrator',
- ]
- for (charm in charms) {
-
- channel = 'latest'
- if (BRANCH_NAME.startsWith('v')) {
- channel = BRANCH_NAME.substring(1)
- } else if (BRANCH_NAME != 'master') {
- channel += '/' + BRANCH_NAME.replaceAll('/', '-')
- }
-
- withCredentials([string(credentialsId: 'Charmstore', variable: 'CHARMCRAFT_AUTH')]) {
- sh "charmcraft status $charm --format json > ${charm}.json"
- isCharm = sh(returnStdout: true, script: "grep architecture ${charm}.json | wc -l").trim() as int
- resourceArgument = ""
- if (isCharm) {
- jqScriptEdge = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$channel/edge/merged\")| .version'|head -1"
- jqScriptBeta = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$channel/beta\")| .version'|head -1"
- index=0
- while (index < 5) {
- resourceNameScript = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$channel/edge/merged\")| .resources[$index].name'|head -1"
- resourceRevsScript = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$channel/edge/merged\")| .resources[$index].revision'|head -1"
- resourceName = sh(returnStdout: true, script: resourceNameScript).trim()
- resourceRevs = sh(returnStdout: true, script: resourceRevsScript).trim()
- if (resourceName != "null") {
- resourceArgument += " --resource ${resourceName}:${resourceRevs}"
- } else {
- break
- }
- index ++
- }
- } else {
- jqScriptEdge = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[].releases[] | select(.channel==\"$channel/edge/merged\")| .version'|head -1"
- jqScriptBeta = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[].releases[] | select(.channel==\"$channel/beta\")| .version'|head -1"
- }
- // edge/merged is used in place of /edge as 10.1.0 LTS uses latest/edge
- edge_rev = sh(returnStdout: true, script: jqScriptEdge).trim()
- beta_rev = sh(returnStdout: true, script: jqScriptBeta).trim()
- try { edge_rev = edge_rev as int } catch (NumberFormatException nfe) {edge_rev = 0}
- try { beta_rev = beta_rev as int } catch (NumberFormatException nfe) {beta_rev = 0}
-
- print "Edge: $edge_rev, Beta: $beta_rev $resourceArgument"
-
- if (edge_rev > beta_rev) {
- print "Promoting $edge_rev to beta in place of $beta_rev"
- beta_track = channel + 'beta'
- sh "charmcraft release ${charm} --revision=${edge_rev} ${resourceArgument} --channel=${channel}/beta"
- }
-
- }
- }
- } // stage('Charm promotion')