if (fileExists('snap/snapcraft.yaml')) {
stage('Snap build') {
- sh "docker pull snapcore/snapcraft:stable"
- 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 ( !JOB_NAME.contains('merge') ) {
- REV="/"+"${GERRIT_REFSPEC}".replaceAll('/','-')
+ 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 ( !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 "snapcraft push --release=${channel}/edge${REV} ${mdg}.snap"
+ sh "sudo rm -rf ${WORKSPACE}/*.snap"
}
- 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"
}
}
parallel parallelSteps
}
- stage("Snap promotion") {
- def snaps = ["osmclient"]
- sh "snapcraft login --with ~/.snapcraft/config"
- 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()
- print "edge rev is $edge_rev"
- track=channel+"beta\\*"
- beta_rev=sh(returnStdout: true,
- script: "snapcraft revisions $snap | " +
- "grep \"$track\" | tail -1 | awk '{print \$1}'").trim()
- print "beta rev is $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') {
+ 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()
+ print "edge rev is $edge_rev"
+ track = channel + 'beta\\*'
+ beta_rev = sh(returnStdout: true,
+ script: "snapcraft revisions $snap | " +
+ "grep \"$track\" | tail -1 | awk '{print \$1}'").trim()
+ print "beta rev is $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")