-
Notifications
You must be signed in to change notification settings - Fork 9
/
Jenkinsfile.content
86 lines (74 loc) · 2.79 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
@Library('va.gov-devops-jenkins-lib') _
// NOTE this job is expected to run in two contexts:
//
// 1. This job will be triggered by the content-build production
// release pipeline also known as the daily auto-deploy
// http://jenkins.vfs.va.gov/job/deploys/job/vets-gov-autodeploy-content-build/
// 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 main 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("content-build", branch: "main")
}
def jobFailed = false
def refStatusState
while({
echo "checking build status..."
refStatusState = getGithubCommitState("content-build", 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 content-build commit ${ref}."
echo "${message}"
slackSend(message: "${message}",
color: "warning",
channel: "cms-notifications")
currentBuild.result = 'FAILURE'
return
}
dir("content-build") {
checkout scm: [$class: 'GitSCM', branches: [[name: ref]], userRemoteConfigs: [[credentialsId: 'va-bot', url: '[email protected]:department-of-veterans-affairs/content-build.git']]]
}
def commonStages = load "content-build/jenkins/common.groovy"
// Setup stage
dockerContainer = commonStages.setup()
stage("Build") {
commonStages.build(ref, dockerContainer, ref, params.env, false, true, '/application')
}
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/content-build-${params.env}", ref, true)
message = "Web content refresh in ${params.env} completed."
echo "${message}"
slackSend(message: "${message}",
color: "good",
channel: "cms-notifications")
}
}
}