forked from alphagov/govuk-content-schemas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
131 lines (111 loc) · 3.22 KB
/
Jenkinsfile
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env groovy
library("govuk")
REPOSITORY = 'govuk-content-schemas'
def dependentApplications = [
'calculators',
'collections-publisher',
'collections',
'contacts',
'content-data-api',
'content-publisher',
'content-store',
'content-tagger',
'email-alert-frontend',
'email-alert-service',
'feedback',
'finder-frontend',
'frontend',
'government-frontend',
'hmrc-manuals-api',
'info-frontend',
'licencefinder',
'manuals-frontend',
'manuals-publisher',
'publisher',
'publishing-api',
'search-api',
'search-admin',
'service-manual-frontend',
'service-manual-publisher',
'short-url-manager',
'smartanswers',
'specialist-publisher',
'static',
'whitehall',
]
node {
properties([
buildDiscarder(
logRotator(
numToKeepStr: '50')
),
[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
])
try {
stage("Checkout") {
checkout scm
env.GIT_COMMIT_HASH = govuk.getFullCommitHash()
}
stage("Merge master") {
govuk.mergeMasterBranch();
}
stage("bundle install") {
govuk.bundleApp();
}
stage("Lint Ruby") {
govuk.runRakeTask("lint")
}
stage("Run tests") {
govuk.runRakeTask("spec")
}
stage("Check generated schemas are up-to-date") {
govuk.runRakeTask("build")
schemasAreUpToDate = sh(script: "git diff --exit-code", returnStatus: true) == 0
if (!schemasAreUpToDate) {
error("Changes to checked-in files detected after running 'rake build'. "
+ "If these are generated files, you might need to run 'rake build' "
+ "to ensure they are regenerated and push the changes.")
}
}
if (env.BRANCH_NAME == 'master') {
stage("Push release tag") {
govuk.pushTag(REPOSITORY, env.BRANCH_NAME, 'release_' + env.BUILD_NUMBER)
}
govuk.deployIntegration(REPOSITORY, env.BRANCH_NAME, 'release_' + env.BUILD_NUMBER, 'deploy')
}
} catch (e) {
currentBuild.result = "FAILED"
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: '[email protected]',
sendToIndividuals: true])
throw e
}
}
// Run schema tests outside of 'node' definition, so that they do not block the
// original executor while the downstream tests are being run
stage("Check dependent projects against updated schema") {
def dependentBuilds = [:]
for (dependentApp in dependentApplications) {
// Dummy parameter to prevent mutation of the parameter used
// inside the closure below. If this is not defined, all of the
// builds will be for the last application in the array.
def app = dependentApp
dependentBuilds[app] = {
start = System.currentTimeMillis()
build job: "/${app}/deployed-to-production",
parameters: [
[$class: 'BooleanParameterValue',
name: 'IS_SCHEMA_TEST',
value: true],
[$class: 'StringParameterValue',
name: 'SCHEMA_BRANCH',
value: env.BRANCH_NAME],
[$class: 'StringParameterValue',
name: 'SCHEMA_COMMIT',
value: env.GIT_COMMIT_HASH]
], wait: false
}
}
parallel dependentBuilds
}