X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=jenkins%2Fci-pipelines%2Fci_stage_2.groovy;h=5cad17b052af5d8eaf8b21d0941a89eb32b7d3b6;hb=b3ac0c2eb3a011766030c83929f1b859f2d1e24b;hp=4d23cf1759129bbd2538d3c21edf2cde516683fc;hpb=7d74f646120d2fd951c667a7f0bc8f0669ecead3;p=osm%2Fdevops.git diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy index 4d23cf17..5cad17b0 100644 --- a/jenkins/ci-pipelines/ci_stage_2.groovy +++ b/jenkins/ci-pipelines/ci_stage_2.groovy @@ -19,7 +19,7 @@ def project_checkout(url_prefix,project,refspec,revision) { // checkout the project // this is done automaticaly by the multibranch pipeline plugin // git url: "${url_prefix}/${project}" - + sh "git fetch --tags" sh "git fetch origin ${refspec}" if (GERRIT_PATCHSET_REVISION.size() > 0 ) { @@ -42,7 +42,7 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa stage('License Scan') { if (!JOB_NAME.contains('merge')) { sh "devops/tools/license_scan.sh" - } + } else { println("skip the scan for merge") } @@ -79,6 +79,33 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa } } + 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('/','-') + } + 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" + } + } + if ( do_stage_3 ) { stage('Build System') {