generated from hmcts/expressjs-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile_nightly
More file actions
134 lines (124 loc) · 3.81 KB
/
Jenkinsfile_nightly
File metadata and controls
134 lines (124 loc) · 3.81 KB
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
#!groovy
properties([
// H allow predefined but random minute see https://en.wikipedia.org/wiki/Cron#Non-standard_characters
pipelineTriggers([cron('H 07 * * 1-5')]),
parameters([
choice(
name: 'ENVIRONMENT',
choices: ['aat', 'preview'],
description: 'Environment to run the test.'
),
string(
name: 'PR_NUMBER',
defaultValue: '',
description: 'PR number (REQUIRED if environment is preview, leave blank otherwise).'
),
booleanParam(
name: 'CHROME_TESTS',
defaultValue: true,
description: 'Tick the checkbox to run E2E tests in Chrome.'
),
booleanParam(
name: 'FIREFOX_TESTS',
defaultValue: true,
description: 'Tick the checkbox to run E2E tests in Firefox.'
),
booleanParam(
name: 'WEBKIT_TESTS',
defaultValue: true,
description: 'Tick the checkbox to run E2E tests in Webkit.'
),
booleanParam(
name: 'ACCESSIBILITY_TESTS',
defaultValue: true,
description: 'Tick the checkbox to run Accessibility tests.'
),
])
])
@Library("Infrastructure")
def type = "nodejs"
def product = "pcs"
def component = "frontend"
def yarnBuilder = new uk.gov.hmcts.contino.YarnBuilder(this)
withNightlyPipeline(type, product, component) {
validateInputs()
handleEnvironmentSetting()
enableSlackNotifications('#pcs-tech')
enableFortifyScan()
afterSuccess('fortify-scan') {
steps.archiveArtifacts allowEmptyArchive: true,
artifacts: '**/Fortify Scan/**/*'
}
afterAlways('FortifyScan') {
runE2ETests(yarnBuilder)
if (params.ACCESSIBILITY_TESTS) {
runAccessibilityTests(yarnBuilder)
}
}
}
def validateInputs() {
if (params.ENVIRONMENT == 'preview' && (!params.PR_NUMBER?.trim())) {
error("Validation Failed: PR number is required when environment is 'preview'")
}
if (params.ENVIRONMENT == 'preview' && !params.PR_NUMBER.trim().matches("^\\d+\$")) {
error("Validation Failed: PR number must contain only numerical values")
}
}
def handleEnvironmentSetting() {
env.TEST_URL = (params.ENVIRONMENT == 'preview')
? "https://pcs-frontend-pr-${params.PR_NUMBER}.preview.platform.hmcts.net"
: "https://pcs.${params.ENVIRONMENT}.platform.hmcts.net/"
}
def runE2ETests(yarnBuilder) {
env.ENABLE_ALL_PAGE_FUNCTIONAL_TESTS = 'true'
if (params.CHROME_TESTS) {
runE2ETestsForBrowser(yarnBuilder, 'Chrome')
}
if (params.FIREFOX_TESTS) {
runE2ETestsForBrowser(yarnBuilder, 'Firefox')
}
if (params.WEBKIT_TESTS) {
runE2ETestsForBrowser(yarnBuilder, 'Safari')
}
}
def runE2ETestsForBrowser(yarnBuilder, String browser) {
stage("Full E2E Test - ${browser}") {
try {
yarnBuilder.yarn("test:E2e${browser}")
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable: " + Error.toString())
} finally {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: "allure-report",
reportFiles: 'index.html',
reportName: "Full ${browser} E2E Test Report"
])
steps.archiveArtifacts(
allowEmptyArchive: true,
artifacts: 'definitions/test/playwright-report/**'
)
}
}
}
def runAccessibilityTests(yarnBuilder) {
stage("Full Accessibility Test") {
try {
yarnBuilder.yarn("test:accessibility")
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable: " + Error.toString())
} finally {
publishHTML([
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "allure-report",
reportFiles : 'index.html',
reportName : 'Accessibility Test Report'
])
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'reports/tests-results/ManageCasesFunctional/*'
}
}
}