forked from department-of-veterans-affairs/va.gov-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.cd
83 lines (73 loc) · 2.29 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// This file is called from ansible/deployment/config/jenkins-vetsgov/seed_job.groovy
// and is used in the http://jenkins.vfs.va.gov/job/testing/job/cms-test 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()
}
build job: "builds/${params.app}", parameters: [
booleanParam(name: 'release', value: false),
booleanParam(name: 'notify_slack', value: true),
stringParam(name: 'ref', value: commit),
booleanParam(name: 'force_rebuild', value: false)
], wait: true
}
}
stage('Deploy to dev') {
when {
expression {
!shouldBail()
}
}
steps {
sh 'echo SUCCESS, we are in DEV step'
build job: "deploys/${params.app}-vagov-dev", 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
}
}
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. ")
}
}
}