From: Mark Beierl Date: Wed, 29 Nov 2023 11:40:44 +0000 (-0500) Subject: Removing Charm and Snap promotion X-Git-Tag: release-v15.0-start~4 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F71%2F14071%2F2;p=osm%2Fdevops.git Removing Charm and Snap promotion As charms and snaps are no longer maintained after v14.0, this change removes the promotion of charms and snaps in preparation for v15.0 Change-Id: I8f116a01ed0813f360e2f501e1685dccf168dc39 Signed-off-by: Mark Beierl --- diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy index 146a16f0..a5eba643 100644 --- a/jenkins/ci-pipelines/ci_stage_2.groovy +++ b/jenkins/ci-pipelines/ci_stage_2.groovy @@ -100,167 +100,6 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa } } - stage('Snap build') { - if (fileExists('snap/snapcraft.yaml')) { - withCredentials([string(credentialsId: 'Snapstore', variable: 'SNAPCRAFT_STORE_CREDENTIALS')]) { - sh "sudo rm -rf ${WORKSPACE}/stage/ ${WORKSPACE}/parts/ ${WORKSPACE}/prime/ ${WORKSPACE}/*.snap" - sh "sudo snapcraft clean --use-lxd" - sh "snapcraft --use-lxd" - sh "mv ${WORKSPACE}/${mdg}_*.snap ${WORKSPACE}/${mdg}.snap" - sh "sudo rm -rf ${WORKSPACE}/stage/ ${WORKSPACE}/parts/ ${WORKSPACE}/prime/" - - REV="" - if ( ! isMergeJob ) { - REV="/"+"${GERRIT_REFSPEC}".replaceAll('/','-') - } - channel="latest" - if (BRANCH_NAME.startsWith("v")) { - channel=BRANCH_NAME.substring(1) - } else if (BRANCH_NAME!="master") { - REV="/"+BRANCH_NAME+REV.replaceAll('/','-') - } - - sh "snapcraft push --release=${channel}/edge${REV} ${mdg}.snap" - sh "sudo rm -rf ${WORKSPACE}/*.snap" - } - } - } - - stage('Charm build') { - charms = [ - 'installers/charm/bundles/osm', - 'installers/charm/bundles/osm-ha', - 'installers/charm/grafana', - 'installers/charm/mongodb-exporter', - 'installers/charm/mysqld-exporter', - 'installers/charm/osm-lcm', - 'installers/charm/osm-mon', - 'installers/charm/osm-nbi', - 'installers/charm/osm-ng-ui', - 'installers/charm/osm-pol', - 'installers/charm/osm-ro', - 'installers/charm/osm-update-db-operator', - 'installers/charm/prometheus', - 'installers/charm/vca-integrator-operator', - ] - parallelSteps = [:] - concurrency = sh(returnStdout: true, script: "expr `nproc` / 2").trim() as int - for (charmPath in charms) { - def directory = charmPath - if (fileExists("$charmPath/charmcraft.yaml")) { - if (isMergeJob) { - CHECK_CHANGES = "git diff --name-only HEAD^1 -- $directory |wc -l" - } else { - CHECK_CHANGES = "git diff --name-only origin/$GERRIT_BRANCH -- $directory |wc -l" - } - charmsChanged = sh(returnStdout:true, script: CHECK_CHANGES).trim() - - if (charmsChanged != "0") { - println("$directory has changes, rebuilding") - - parallelSteps[directory] = { - waitUntil(quiet: true, initialRecurrencePeriod: 5) { - if (concurrency > 0) { - concurrency-- - true - } else { - sleep 5 - false - } - } - try { - dir("${directory}") { - try { - sh "charmcraft pack --format json --verbosity brief 1> pack.json 2> pack-stderr.log" - } catch (Exception e) { - sh "cat pack-stderr.log" - throw e - } - - 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')]) { - try { - 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, - script: 'cat upload.json | jq -r ".errors[0].message" | grep -v null').trim() - if (errorMessage.contains("already exists")) { - println("No changes, skipping upload") - return 0 - } - sh "cat upload-stderr.log" - throw e - } - def charmRevision = sh( - returnStdout: true, - script: 'cat upload.json | jq -r ".revision"').trim() - - def charmBranch="merged" - if ( !JOB_NAME.contains('merge') ) { - charmBranch="${GERRIT_REFSPEC}".replaceAll('/','-') - } - def channel="latest" - if (BRANCH_NAME.startsWith("v")) { - channel=BRANCH_NAME.substring(1) - } else if (BRANCH_NAME!="master" && JOB_NAME.contains('merge')) { - charmBranch=BRANCH_NAME - } - - def charmName = sh( - returnStdout:true, - script: "if [ -f bundle.yaml ];then cat bundle.yaml;else cat metadata.yaml;fi|yq -r .name").trim() - - def resourceArgument = "" - try { - def resourceName = sh( - returnStdout:true, - script: "cat metadata.yaml | yq '.resources | keys | .[0]'" - ).trim() - if( resourceName != "null" ) { - 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) { - print("No resource associated with bundle, skipping") - } - - print("resourceArgument = $resourceArgument") - - sh "charmcraft release ${charmName} --revision=${charmRevision} ${resourceArgument} --channel=${channel}/edge/${charmBranch}" - } - } - } finally { - concurrency++ - } - } - } - } - } - parallel parallelSteps - } if ( do_stage_3 ) { stage('Build System') { def downstream_params_stage_3 = [ diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index 90cd9f7b..dd876fce 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -685,104 +685,6 @@ EOF""" } parallel parallelSteps } - 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 = [ - [name: 'osm', base: "22.04"], - [name: 'osm-ha', base: "22.04"], - [name: 'mongodb-exporter-k8s', base: "20.04"], - [name: 'mysqld-exporter-k8s', base: "20.04"], - [name: 'osm-grafana', base: "20.04"], - [name: 'osm-keystone', base: "22.04"], - [name: 'osm-lcm', base: "22.04"], - [name: 'osm-mon', base: "22.04"], - [name: 'osm-nbi', base: "22.04"], - [name: 'osm-ng-ui', base: "22.04"], - [name: 'osm-pol', base: "22.04"], - [name: 'osm-ro', base: "22.04"], - [name: 'osm-prometheus', base: "20.04"], - [name: 'osm-update-db-operator', base: "20.04"], - [name: 'osm-vca-integrator', base: "22.04"], - ] - for (entry in charms) { - charm = entry.name - base = entry.base - 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 2>/dev/null").trim() as int - resourceArgument = "" - if (isCharm) { - jqScriptEdge = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .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==\"$base\") | .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==\"$base\") | .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==\"$base\") | .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') } // if (params.DO_DOCKERPUSH) } // stage('Archive') } // if (params.SAVE_ARTIFACTS_OVERRIDE || stage_archive)