@@ -13,6 +13,7 @@ pipeline {
1313 options {
1414 buildDiscarder(logRotator(numToKeepStr : ' 15' ))
1515 disableConcurrentBuilds()
16+ skipStagesAfterUnstable()
1617 }
1718 environment {
1819 COMPOSE_PROJECT_NAME = " hapifhir${ BRANCH_NAME} "
@@ -62,13 +63,25 @@ pipeline {
6263 }
6364 steps {
6465 withCredentials([file(credentialsId : ' 8da5ba56-8ebb-4a6a-bdb5-43c9d0efb120' , variable : ' ENV_FILE' )]) {
65- sh( script : " ./ci-buildImage.sh" )
66+ script {
67+ try {
68+ sh( script : " ./ci-buildImage.sh" )
69+ }
70+ catch (exc) {
71+ currentBuild. result = ' UNSTABLE'
72+ }
73+ }
6674 }
6775 }
6876 post {
6977 success {
7078 archive ' build/libs/*.jar,build/resources/main/api-definition.html, build/resources/main/ version.properties'
7179 }
80+ unstable {
81+ script {
82+ notifyAfterFailure()
83+ }
84+ }
7285 failure {
7386 script {
7487 notifyAfterFailure()
@@ -108,10 +121,17 @@ pipeline {
108121 steps {
109122 withSonarQubeEnv(' Sonar OpenLMIS' ) {
110123 withCredentials([string(credentialsId : ' SONAR_LOGIN' , variable : ' SONAR_LOGIN' ), string(credentialsId : ' SONAR_PASSWORD' , variable : ' SONAR_PASSWORD' )]) {
111- sh(script : " ./ci-sonarAnalysis.sh" )
124+ script {
125+ try {
126+ sh(script : " ./ci-sonarAnalysis.sh" )
112127
113- // workaround: Sonar plugin retrieves the path directly from the output
114- sh ' echo "Working dir: ${WORKSPACE}/build/sonar"'
128+ // workaround: Sonar plugin retrieves the path directly from the output
129+ sh ' echo "Working dir: ${WORKSPACE}/build/sonar"'
130+ }
131+ catch (exc) {
132+ currentBuild. result = ' UNSTABLE'
133+ }
134+ }
115135 }
116136 }
117137 timeout(time : 1 , unit : ' HOURS' ) {
@@ -124,6 +144,11 @@ pipeline {
124144 }
125145 }
126146 post {
147+ unstable {
148+ script {
149+ notifyAfterFailure()
150+ }
151+ }
127152 failure {
128153 script {
129154 notifyAfterFailure()
@@ -192,9 +217,9 @@ pipeline {
192217def notifyAfterFailure () {
193218 BRANCH = " ${ env.GIT_BRANCH} " . trim()
194219 if (BRANCH . equals(" master" ) || BRANCH . startsWith(" rel-" )) {
195- slackSend color : ' danger' , message : " ${ env.JOB_NAME} - #${ env.BUILD_NUMBER} ${ env.STAGE_NAME} FAILED (<${ env.BUILD_URL} |Open>)"
220+ slackSend color : ' danger' , message : " ${ env.JOB_NAME} - #${ env.BUILD_NUMBER} ${ env.STAGE_NAME} ${ currentBuild.result } (<${ env.BUILD_URL} |Open>)"
196221 }
197- emailext subject : " ${ env.JOB_NAME} - #${ env.BUILD_NUMBER} ${ env.STAGE_NAME} FAILED " ,
198- body : """ <p>${ env.JOB_NAME} - #${ env.BUILD_NUMBER} ${ env.STAGE_NAME} FAILED </p><p>Check console <a href="${ env.BUILD_URL} ">output</a> to view the results.</p>""" ,
222+ emailext subject : " ${ env.JOB_NAME} - #${ env.BUILD_NUMBER} ${ env.STAGE_NAME} ${ currentBuild.result } " ,
223+ body : """ <p>${ env.JOB_NAME} - #${ env.BUILD_NUMBER} ${ env.STAGE_NAME} ${ currentBuild.result } </p><p>Check console <a href="${ env.BUILD_URL} ">output</a> to view the results.</p>""" ,
199224 recipientProviders : [[$class : ' CulpritsRecipientProvider' ], [$class : ' DevelopersRecipientProvider' ]]
200225}
0 commit comments