Cherry picks from master 70/10270/1
authorbeierlm <mark.beierl@canonical.com>
Mon, 8 Feb 2021 16:10:53 +0000 (11:10 -0500)
committerbeierlm <mark.beierl@canonical.com>
Mon, 8 Feb 2021 16:11:23 +0000 (11:11 -0500)
https://osm.etsi.org/gerrit/c/osm/devops/+/10223
https://osm.etsi.org/gerrit/c/osm/devops/+/10195
https://osm.etsi.org/gerrit/c/osm/devops/+/10142

Change-Id: I80cb5afe884c03a6e97553b4b805fc98c4a5e41b
Signed-off-by: beierlm <mark.beierl@canonical.com>
jenkins/ci-pipelines/ci_stage_1.groovy
jenkins/ci-pipelines/ci_stage_2.groovy
jenkins/ci-pipelines/ci_stage_3.groovy

index 53466f7..0f530c5 100644 (file)
@@ -96,7 +96,7 @@ node("${params.NODE}") {
         println("TEST_INSTALL = ${params.TEST_INSTALL}, downstream job: ${downstream_job_name}")
                currentBuild.result = 'SUCCESS'
         try {
-           stage_3_merge_result = build job: "${downstream_job_name}", parameters: downstream_params, propagate: true
+            stage_3_merge_result = build job: "${downstream_job_name}", parameters: downstream_params, propagate: true
             if (stage_3_merge_result.getResult() != 'SUCCESS') {
                 project = stage_3_merge_result.getProjectName()
                 build = stage_3_merge_result.getNumber()
@@ -104,28 +104,26 @@ node("${params.NODE}") {
                            // error("${project} build ${build} failed")
                                currentBuild.result = stage_3_merge_result.getResult()
             }
-               }
-               catch(caughtError) {
-                echo 'Exception in stage_1'
-                currentBuild.result = 'FAILURE'
-               }
-               finally {
-                   try {
-                        if((currentBuild.result != 'SUCCESS') && (env.JOB_NAME == 'daily-stage_4')){
-               emailext (
-                   subject: "[OSM-Jenkins] Job: ${env.JOB_NAME} Build: ${env.BUILD_NUMBER} Result: ${currentBuild.result}",
-                   body: """ Check console output at "${env.BUILD_URL}"  """,
-                   to: 'OSM_MDL@list.etsi.org',
-                   recipientProviders: [culprits()]
-                )
+       }
+        catch(caughtError) {
+            echo 'Exception in stage_1'
+            currentBuild.result = 'FAILURE'
+        }
+        finally {
+            try {
+                if((currentBuild.result != 'SUCCESS') && (env.JOB_NAME == 'daily-stage_4')){
+                    emailext (
+                        subject: "[OSM-Jenkins] Job: ${env.JOB_NAME} Build: ${env.BUILD_NUMBER} Result: ${currentBuild.result}",
+                        body: """ Check console output at "${env.BUILD_URL}"  """,
+                        to: 'OSM_MDL@list.etsi.org',
+                        recipientProviders: [culprits()]
+                    )
+                }
             }
-                 }
-                 catch(caughtError) {
-                   echo "Failure in executing email"
-                 }
-
-               }
-    } 
+            catch(caughtError) {
+                echo "Failure in executing email"
+            }
+        }
+    }
+}
 
-       
- }
index 616f569..5cad17b 100644 (file)
@@ -81,16 +81,16 @@ 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 "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 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') ) {
-                short_ref=sh(returnStdout: true,
-                    script: "git rev-parse --short HEAD").trim()
-                REV="/"+short_ref
+                REV="/"+"${GERRIT_REFSPEC}".replaceAll('/','-')
             }
             channel="latest"
             if (BRANCH_NAME.startsWith("v")) {
@@ -102,6 +102,7 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa
             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"
         }
     }
 
index 4ba5630..6e23ba3 100644 (file)
@@ -32,7 +32,7 @@ properties([
         string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER'),
         string(defaultValue: 'osm-stage_4', description: '', name: 'DOWNSTREAM_STAGE_NAME'),
         string(defaultValue: 'testing-daily', description: '', name: 'DOCKER_TAG'),
-        booleanParam(defaultValue: true, description: '', name: 'SAVE_CONTAINER_ON_FAIL'),
+        booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_FAIL'),
         booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS'),
         booleanParam(defaultValue: true, description: '', name: 'SAVE_ARTIFACTS_ON_SMOKE_SUCCESS'),
         booleanParam(defaultValue: true, description: '', name: 'DO_STAGE_4'),