+ REV=""
+ if ( !JOB_NAME.contains('merge') ) {
+ 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 "sudo docker run -v ~/.snapcraft:/snapcraft -v ${WORKSPACE}:/build " +
+ "-w /build snapcore/snapcraft:stable /bin/bash -c " +
+ "\"snapcraft login --with /snapcraft/config ; snapcraft push --release=${channel}/edge${REV} ${mdg}.snap\""
+ sh "sudo rm -rf ${WORKSPACE}/*.snap"
+ }
+ }