-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_nightly
177 lines (168 loc) · 5.15 KB
/
Jenkinsfile_nightly
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!groovy
properties([
// Currently, we run this pipeline on the first monday of every month (for resources sake)
// If you want to run this nightly, uncomment the below line
// pipelineTriggers([cron('H 8 * * 1-5')]),
pipelineTriggers([cron('H 8 1-7 * 1')]),
disableConcurrentBuilds(),
parameters([
string(
name: 'CITIZEN_FRONTEND_BASE_URL',
defaultValue: 'https://privatelaw.aat.platform.hmcts.net/',
description: 'The Citizen URL to test against'
),
string(
name: 'MANAGE_CASES_BASE_URL',
defaultValue: 'https://manage-case.aat.platform.hmcts.net/cases',
description: 'The Manage Cases URL to test against'
),
string(
name: 'FUNCTIONAL_TESTS_WORKERS',
defaultValue: '4',
description: 'Number of workers running functional tests'
),
string(
name: 'TAGS_TO_RUN',
defaultValue: '',
description: 'Optionally, run a single or multiple tags (comma separated e.g. @cui, @exui)'
),
])
])
@Library("Infrastructure")
// Replace these with your own teams info
def type = "nodejs"
def product = "dtsse"
def component = "e2e-tests"
def channel = "#tcoe-builds"
static Map < String, Object > secret(String secretName, String envVariable) {
[
$class: 'AzureKeyVaultSecret',
secretType: 'Secret',
name: secretName,
envVariable: envVariable
]
}
// Replace the key vault name with your own service
def secrets = [
'prl-${env}': [
secret('solicitor-user', 'EXUI_USERNAME'),
secret('solicitor-password', 'EXUI_PASSWORD'),
secret('citizen-user', 'CITIZEN_USERNAME'),
secret('citizen-password', 'CITIZEN_PASSWORD'),
]
]
def buildPlaywrightCommand(tags) {
if (tags == null || tags.trim().isEmpty()) {
return;
}
def tagList = tags.split(',').collect { it.trim() }
def command = 'playwright test tests/'
tagList.each { tag ->
if (!tag.isEmpty()) {
command += " --grep ${tag}"
}
}
return command
}
def yarnBuilder = new uk.gov.hmcts.contino.YarnBuilder(this)
withNightlyPipeline(type, product, component, 600) {
loadVaultSecrets(secrets)
env.CITIZEN_FRONTEND_BASE_URL = params.CITIZEN_FRONTEND_BASE_URL
env.MANAGE_CASES_BASE_URL = params.MANAGE_CASES_BASE_URL
env.FUNCTIONAL_TESTS_WORKERS = params.FUNCTIONAL_TESTS_WORKERS
enableSlackNotifications(channel)
afterAlways('DependencyCheckNightly') {
stage('Set up playwright') {
try {
yarnBuilder.yarn('setup')
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable: " + Error.toString())
}
}
if (!TAGS_TO_RUN.isEmpty()) {
stage("${TAGS_TO_RUN} E2E Tests") {
try {
currentBuild.displayName = "${TAGS_TO_RUN} E2E Tests"
yarnBuilder.yarn(buildPlaywrightCommand(TAGS_TO_RUN))
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable: " + Error.toString())
} finally {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: "playwright-report",
reportFiles: 'index.html',
reportName: "${TAGS_TO_RUN} E2E Tests"
])
}
}
} else {
currentBuild.displayName = "All E2E Tests"
stage('Chrome E2E Tests') {
try {
yarnBuilder.yarn('test:chrome')
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable: " + Error.toString())
} finally {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: "playwright-report",
reportFiles: 'index.html',
reportName: 'Chrome E2E Tests'
])
}
}
stage('Firefox E2E Tests') {
try {
yarnBuilder.yarn('test:firefox')
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable: " + Error.toString())
} finally {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: "playwright-report",
reportFiles: 'index.html',
reportName: 'Firefox E2E Tests'
])
}
}
stage('Webkit E2E Tests') {
try {
yarnBuilder.yarn('test:webkit')
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable: " + Error.toString())
} finally {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: "playwright-report",
reportFiles: 'index.html',
reportName: 'Webkit E2E Tests'
])
}
}
stage('Accessibiity Tests') {
try {
yarnBuilder.yarn('test:a11y')
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable: " + Error.toString())
} finally {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: "playwright-report",
reportFiles: 'index.html',
reportName: 'Accessibility Tests'
])
}
}
}
}
}