-
Notifications
You must be signed in to change notification settings - Fork 5
/
Jenkinsfile.cd
69 lines (60 loc) · 1.92 KB
/
Jenkinsfile.cd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// This file is sourced from ansible/deployment/config/jenkins-vetsgov/seed_job.groovy
// and is used in the http://jenkins.vfs.va.gov/job/testing/job/cms job that
// auto-triggers deploys to DEV & STAGING on commit and which is triggered
// by a webhook.
def shouldBail() {
// abort the job if there's a newer build going now
return currentBuild.nextBuild
}
pipeline {
agent any
stages {
stage('Checkout Code') {
steps {
checkout scm
}
}
stage('Build new AMI') {
when {
expression {
!shouldBail()
}
}
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),
booleanParam(name: 'force_rebuild', value: true)
], wait: true
}
}
}
stage('Deploy to STAGING') {
when {
expression {
!shouldBail()
}
}
steps {
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),
booleanParam(name: 'migration_status', value: false)
] , wait: false
}
}
}
post {
// Intentionally do not cleanWs() here so that we can use previous commit to ignore certain polling paths.
failure {
slackSend(channel: params.slack_channel, color: 'danger', message: "Deployment for ${env.JOB_NAME} failed ${env.BUILD_URL}, please leave a checkmark emoji here to indicate ownership of failure. ")
}
}
}