limit building deployment artifact
Gitea Bucky/url-shortener/pipeline/head There was a failure building this commit Details

+ added buildArtifact variable and set it to true
+ in auditing stage, if there's an error, set buildArtifact to false
+ in build artifact stage, if buildArtifact is true, build  it
pull/34/head
Adam Townsend 2023-10-23 14:58:02 -07:00
parent de3dcc48ab
commit 7c0f6eb603
1 changed files with 17 additions and 3 deletions

20
Jenkinsfile vendored
View File

@ -1,3 +1,5 @@
def buildArtifact = true
pipeline { pipeline {
agent { label 'ruby && freebsd' } agent { label 'ruby && freebsd' }
@ -25,8 +27,16 @@ pipeline {
stage('Audit Dependencies') { stage('Audit Dependencies') {
steps { steps {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
sh 'bundle exec ruby-audit check' script {
sh 'bundle exec bundle-audit check >> audit.html' try {
sh 'bundle exec ruby-audit check'
sh 'bundle exec bundle-audit check >> audit.html'
} catch (e) {
script {
buildArtifact = false
}
}
}
} }
} }
} }
@ -61,7 +71,11 @@ pipeline {
} }
stage('Build production deliverable') { stage('Build production deliverable') {
steps { steps {
echo "BUILD RESULT: ${buildResult}" when {
expression {
buildArtifact
}
}
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
sh ''' #!/usr/local/bin/bash sh ''' #!/usr/local/bin/bash
ZIP_FILE="url-shortener_${BRANCH_NAME}_$(date "+%Y-%m-%d_%H-%M-%S").tgz" ZIP_FILE="url-shortener_${BRANCH_NAME}_$(date "+%Y-%m-%d_%H-%M-%S").tgz"