diff --git a/Jenkinsfile.cd b/Jenkinsfile.cd index fca210c95..83e7d69aa 100644 --- a/Jenkinsfile.cd +++ b/Jenkinsfile.cd @@ -11,6 +11,10 @@ def shouldBail() { pipeline { agent any + environment { + commit = '' + } + parameters { booleanParam(name: 'SKIP_BUILD', defaultValue: false, description: 'Set to true to skip the stage') booleanParam(name: 'SKIP_DEPLOY', defaultValue: false, description: 'Set to true to skip the stage') @@ -23,6 +27,14 @@ pipeline { } } + stage('Set Commit') { + steps { + script { + env.commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim() + } + } + } + stage('Build new AMI') { when { @@ -33,16 +45,12 @@ pipeline { } steps { - script { - commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim() - } - retry(3){ build job: "builds/${params.app}", parameters: [ booleanParam(name: 'release', value: false), booleanParam(name: 'notify_slack', value: true), stringParam(name: 'slack_channel', value: "${params.slack_channel}"), - stringParam(name: 'ref', value: commit), + stringParam(name: 'ref', value: env.commit), booleanParam(name: 'force_rebuild', value: true) ], wait: true } @@ -50,6 +58,7 @@ pipeline { } stage('Deploy to STAGING') { + when { allOf { expression { return !params.SKIP_DEPLOY } @@ -61,7 +70,7 @@ pipeline { build job: "deploys/${params.app}-vagov-staging", parameters: [ stringParam(name: 'app', value: params.app), booleanParam(name: 'notify_slack', value: true), - stringParam(name: 'ref', value: commit), + stringParam(name: 'ref', value: env.commit), booleanParam(name: 'migration_status', value: false) ] , wait: false }