diff --git a/Jenkinsfile b/Jenkinsfile index a5b1168..4053714 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,12 +38,18 @@ pipeline { env.CI=false env.FRONTEND_NAME = (env.GITHUB_COMMENT =~ /@eea-jenkins check bundle on (\S+).*$/)[ 0 ][ 1 ] sh '''rm -rf ${FRONTEND_NAME}''' - sh '''git clone -b develop https://github.com/eea/${FRONTEND_NAME}.git''' + try { + sh '''git clone -b develop https://github.com/eea/${FRONTEND_NAME}.git''' + } + catch (Exception e) { + sh '''echo "Error cloning develop branch on https://github.com/eea/${FRONTEND_NAME}.git" > result.txt''' + exit 1 + } dir(env.FRONTEND_NAME) { sh """cat mrs.developer.json | jq 'if ( has("'$GIT_NAME'") ) then .["'$GIT_NAME'"].branch = "'$CHANGE_BRANCH'" else . end' > temp""" sh """mv temp mrs.developer.json""" sh """cat mrs.developer.json | jq '.["'$GIT_NAME'"]' """ - sh '''if [ $(grep "eea/"${GIT_NAME}".git" mrs.developer.json | wc -l) -eq 0 ]; then exit 1; fi''' + sh '''if [ $(grep "eea/"${GIT_NAME}".git" mrs.developer.json | wc -l) -eq 0 ]; then echo "Volto addon does not exist in mrs.developer.json on develop branch on https://github.com/eea/${FRONTEND_NAME}.git" > ../result.txt; exit 1; fi''' sh """yarn""" sh """make develop""" sh """make install""" @@ -63,9 +69,9 @@ pipeline { post { failure { script { - sh """cat ${FRONTEND_NAME}/checkresult.txt | grep -v 'https://service.bundlewatch.io/results' > ${FRONTEND_NAME}/result.txt""" + sh """if [ -f ${FRONTEND_NAME}/checkresult.txt ] ; then cat ${FRONTEND_NAME}/checkresult.txt | grep -v 'https://service.bundlewatch.io/results' > result.txt; fi""" publishChecks name: "Bundlewatch on ${env.FRONTEND_NAME}", title: "Bunde size check on ${env.FRONTEND_NAME}", summary: "Result of bundlewatch run on ${env.FRONTEND_NAME}", - text: readFile(file: "${env.FRONTEND_NAME}/result.txt"), conclusion: "${currentBuild.currentResult}", + text: readFile(file: "result.txt"), conclusion: "${currentBuild.currentResult}", detailsURL: "${env.BUILD_URL}display/redirect" pullRequest.comment("### :x: Bundlewatch check job on ${FRONTEND_NAME} FAILED\n\nCheck ${BUILD_URL} for details\n\n:fire: @${GITHUB_COMMENT_AUTHOR}")