+
+ 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\"")
+ }
+ }
+ }