From b3ac0c2eb3a011766030c83929f1b859f2d1e24b Mon Sep 17 00:00:00 2001 From: beierlm Date: Mon, 8 Feb 2021 11:10:53 -0500 Subject: [PATCH] Cherry picks from master 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 --- jenkins/ci-pipelines/ci_stage_1.groovy | 46 ++++++++++++-------------- jenkins/ci-pipelines/ci_stage_2.groovy | 11 +++--- jenkins/ci-pipelines/ci_stage_3.groovy | 2 +- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/jenkins/ci-pipelines/ci_stage_1.groovy b/jenkins/ci-pipelines/ci_stage_1.groovy index 53466f75..0f530c52 100644 --- a/jenkins/ci-pipelines/ci_stage_1.groovy +++ b/jenkins/ci-pipelines/ci_stage_1.groovy @@ -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" + } + } + } +} - - } diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy index 616f569f..5cad17b0 100644 --- a/jenkins/ci-pipelines/ci_stage_2.groovy +++ b/jenkins/ci-pipelines/ci_stage_2.groovy @@ -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" } } diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index 4ba56307..6e23ba38 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -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'), -- 2.25.1