summaryrefslogtreecommitdiffci
path: root/Jenkinsfile
diff options
from:
to:
context:
space:
mode:
authorGravatar Saya Andy <saya.andy@posteo.com> 2026-06-22 21:24:00 +0700
committerGravatar Saya Andy <saya.andy@posteo.com> 2026-06-22 21:24:00 +0700
commit1c54aa1c4d87966e37dda72630642943a022b09c (patch)
tree279d1f014d8cbe30a67dfa812434c16c074b03aa /Jenkinsfile
parent7737b91fccbff3da84342a6974df35ee59737dcb (diff)
downloadweb-1c54aa1c4d87966e37dda72630642943a022b09c.tar.gz
web-1c54aa1c4d87966e37dda72630642943a022b09c.zip
fix: try to catch exception on build step
Diffstat (limited to 'Jenkinsfile')
-rw-r--r--Jenkinsfile24
1 files changed, 15 insertions, 9 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
index 586cd0e..f565210 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -48,15 +48,21 @@ spec:
container(name: 'kaniko', shell: '/busybox/sh') {
withCredentials([file(credentialsId: 'registry-sayagit-jenkins-password', variable: 'REGISTRY_SAYAGIT_JENKINS_PASSWORD')]) {
withEnv(['PATH+EXTRA=/busybox']) {
- sh '''#!/busybox/sh
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"https://registry.sayag.it\":{\"username\":\"jenkins\",\"password\":\"$REGISTRY_SAYAGIT_JENKINS_PASSWORD\"}}}" > /kaniko/.docker/config.json
- pushToTags="$IMAGE_PUSH_DESTINATION:latest $IMAGE_PUSH_DESTINATION:commit-`git rev-parse --short HEAD`"
- if [ "$TAG_NAME" != "" ]; then
- pushToTags="$pushToTags $IMAGE_PUSH_DESTINATION:stable $IMAGE_PUSH_DESTINATION:$TAG_NAME"
- fi
- /kaniko/executor --context `pwd` --destination $pushToTags
- '''
+ try {
+ sh '''#!/busybox/sh
+ mkdir -p /kaniko/.docker
+ echo "{\"auths\":{\"https://registry.sayag.it\":{\"username\":\"jenkins\",\"password\":\"$REGISTRY_SAYAGIT_JENKINS_PASSWORD\"}}}" > /kaniko/.docker/config.json
+ pushToTags="$IMAGE_PUSH_DESTINATION:latest $IMAGE_PUSH_DESTINATION:commit-`git rev-parse --short HEAD`"
+ if [ "$TAG_NAME" != "" ]; then
+ pushToTags="$pushToTags $IMAGE_PUSH_DESTINATION:stable $IMAGE_PUSH_DESTINATION:$TAG_NAME"
+ fi
+ /kaniko/executor --context `pwd` --destination $pushToTags
+ '''
+ } catch (Exception e) {
+ echo "Caught exception: ${e.getMessage()}"
+ currentBuild.result = 'FAILURE'
+ throw e
+ }
}
}
}