From 6af13d985d477a5a09cfef8362192de757308719 Mon Sep 17 00:00:00 2001 From: beierlm Date: Thu, 20 Aug 2020 16:49:40 -0400 Subject: [PATCH] Promote snaps to beta Adds logic to check if the snap in the edge channel is newer than the beta channel. If so, promote the edge snap to beta. Change-Id: I27bf9ca01b9ed6cf177addffeedc0fa29aae6bb5 Signed-off-by: beierlm --- jenkins/ci-pipelines/ci_stage_3.groovy | 65 ++++++++++++++++++++------ 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index 0428fa1e..8f79cd47 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -17,7 +17,7 @@ /* Change log: * 1. Bug 745 : Jayant Madavi, Mrityunjay Yadav : JM00553988@techmahindra.com : 23-july-2019 : Improvement to the code, typically we have 2 * or more branches whose build gets triggered, ex master & release branch, the previous code was removing any/all docker. - * Now removing previous docker of the same branch, so that the other branch failed docker should not be removed. It also + * Now removing previous docker of the same branch, so that the other branch failed docker should not be removed. It also * acts as clean-up for previous docker remove failure. * 2. Feature 7829 : Mrityunjay Yadav, Jayant Madavi: MY00514913@techmahindra.com : 19-Aug-2019 : Added a parameters & function to invoke Robot test. */ @@ -271,14 +271,14 @@ node("${params.NODE}") { { repo_base_url = "-u ${params.REPOSITORY_BASE}" } - if ( params.DO_STAGE_4 ) { - try { + if ( params.DO_STAGE_4 ) { + try { sh "docker stack list |grep \"${container_name_prefix}\"| awk '{ print \$1 }'| xargs docker stack rm" - } - catch (caughtError) { - println("Caught error: docker stack rm failed!") - } - } + } + catch (caughtError) { + println("Caught error: docker stack rm failed!") + } + } sh """ export PATH=$PATH:/snap/bin installers/full_install_osm.sh -y -s ${container_name} --test --nolxd --nodocker --nojuju --nohostports --nohostclient \ @@ -306,9 +306,9 @@ node("${params.NODE}") { if ( ! currentBuild.result.equals('UNSTABLE') ) { stage_archive = keep_artifacts } else { - error = new Exception("Smoke test failed") - currentBuild.result = 'FAILURE' - } + error = new Exception("Smoke test failed") + currentBuild.result = 'FAILURE' + } } } @@ -327,10 +327,10 @@ node("${params.NODE}") { stage_archive = keep_artifacts } else { println ("Systest test failed, throwing error") - error = new Exception("Systest test failed") - currentBuild.result = 'FAILURE' - throw error - } + error = new Exception("Systest test failed") + currentBuild.result = 'FAILURE' + throw error + } } } @@ -348,6 +348,41 @@ node("${params.NODE}") { stage("Docker Push") { sh "make -C docker push INPUT_TAG=${container_name} TAG=${params.DOCKER_TAG}" } + + stage("Snap promotion") { + def snaps = ["osmclient"] + for (snap in snaps) { + channel="" + 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: "sudo docker run -v ~/.snapcraft:/snapcraft -v ${WORKSPACE}:/build " + + "-w /build snapcore/snapcraft:stable /bin/bash -c " + + "\"snapcraft login --with /snapcraft/config &>/dev/null && " + + "snapcraft revisions $snap\" | " + + "grep \" $track\" | tail -1 | awk '{print \$1}'").trim() + track=channel+"beta\\*" + beta_rev=sh(returnStdout: true, + script: "sudo docker run -v ~/.snapcraft:/snapcraft -v ${WORKSPACE}:/build " + + "-w /build snapcore/snapcraft:stable /bin/bash -c " + + "\"snapcraft login --with /snapcraft/config &>/dev/null && " + + "snapcraft revisions $snap\" | " + + "grep \" $track\" | tail -1 | awk '{print \$1}'").trim() + + if ( edge_rev != beta_rev ) { + print "Promoting $edge_rev to beta in place of $beta_rev" + beta_track=channel+"beta" + sh("sudo docker run -v ~/.snapcraft:/snapcraft -v ${WORKSPACE}:/build " + + "-w /build snapcore/snapcraft:stable /bin/bash -c " + + "\"snapcraft login --with /snapcraft/config &>/dev/null && " + + "snapcraft release $snap $edge_rev $beta_track\"") + } + } + } } } } -- 2.25.1