forked from department-of-veterans-affairs/vets-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.content
93 lines (81 loc) · 2.86 KB
/
Jenkinsfile.content
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
84
85
86
87
88
89
90
91
92
93
@Library('va.gov-devops-jenkins-lib') _
// NOTE this job is expected to run in two contexts:
//
// 1. This job will be triggered by the vets-website production
// release pipeline also known as the daily auto-deploy
// http://jenkins.vfs.va.gov/job/deploys/job/vets-gov-autodeploy-vets-website/
// When run in this context the ref parameter will be populated with
// the ref of the latest release.
//
// 2. This job will be triggered by the CMS (va-cms-bot) in order to
// run a content build and deploy to dev or staging. In this context
// the ref parameter will not be provided and this job will retrieve
// the latest commit SHA from the master branch and wait for a valid
// commit status indicated that it has been deployed and can therefore
// be rebuilt and deployed by this job.
//
// Under no circumstances should this job trigger a production
// deployment. At this point in time all deployments to production
// should be handled through the daily deploy job referenced above.
node('vetsgov-general-purpose') {
refStatusState = ""
ref = params.ref
if (ref == "") {
ref = getLatestGitRef("vets-website", branch: "master")
}
def jobFailed = false
def refStatusState
while({
echo "checking build status..."
refStatusState = getGithubCommitState("vets-website", ref)
if ("${refStatusState}" == "SUCCESS") {
return false
} else if ("${refStatusState}" == "PENDING") {
sleep 60
return true
}
jobFailed = true
return false
}()) continue
if (jobFailed) {
message = "Web content refresh on ${params.env} aborted due to '${refStatusState}' status on vets-website commit ${ref}."
echo "${message}"
slackSend(message: "${message}",
color: "warning",
channel: "cms-notifications")
currentBuild.result = 'FAILURE'
return
}
dir("vets-website") {
checkout scm: [
$class: 'GitSCM',
branches: [[name: ref]],
userRemoteConfigs: [[
credentialsId: 'va-bot',
url: 'git@github.com:department-of-veterans-affairs/vets-website.git']],
extensions: [[ $class: 'PruneStaleBranch' ]]
]
}
def commonStages = load "vets-website/jenkins/common.groovy"
// Setup stage
dockerContainer = commonStages.setup()
stage("Build") {
commonStages.build(ref, dockerContainer, ref, params.env, false, true)
}
stage("Prearchive") {
commonStages.prearchive(dockerContainer, params.env)
}
stage("Archive") {
commonStages.archive(dockerContainer, ref, params.env)
}
stage("Deploy Dev or Staging") {
if (params.env != "vagovprod" && params.deploy) {
commonStages.runDeploy("deploys/vets-website-${params.env}", ref, true)
message = "Web content refresh in ${params.env} completed."
echo "${message}"
slackSend(message: "${message}",
color: "good",
channel: "cms-notifications")
}
}
}