- stage('Archive') {
- sh "mkdir -p changelog"
- sh "devops/tools/generatechangelog-pipeline.sh > changelog/changelog-${mdg}.html"
- sh(returnStdout:true, script: 'devops-stages/stage-archive.sh').trim()
- ci_helper.archive(artifactory_server,mdg,branch,'untested')
+ if (fileExists('snap/snapcraft.yaml')) {
+ stage('Snap build') {
+ sh "sudo rm -rf ${WORKSPACE}/stage/ ${WORKSPACE}/parts/ ${WORKSPACE}/prime/ ${WORKSPACE}/*.snap"
+ sh "docker run -v ${WORKSPACE}:/build --env BRANCH=${BRANCH_NAME} -w /build snapcore/snapcraft:stable /bin/bash -c 'apt update && snapcraft'"
+ sh "sudo mv ${WORKSPACE}/${mdg}_*.snap ${WORKSPACE}/${mdg}.snap"
+ sh "sudo rm -rf ${WORKSPACE}/stage/ ${WORKSPACE}/parts/ ${WORKSPACE}/prime/"
+
+ REV=""
+ if ( !JOB_NAME.contains('merge') ) {
+ short_ref=sh(returnStdout: true,
+ script: "git rev-parse --short HEAD").trim()
+ REV="/"+short_ref
+ }
+ 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\""
+ }