-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile_nightly
More file actions
159 lines (146 loc) · 5.63 KB
/
Jenkinsfile_nightly
File metadata and controls
159 lines (146 loc) · 5.63 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
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
#!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([
booleanParam(
name: 'CHROME_TESTS',
defaultValue: true,
description: 'Run E2E tests in Chrome (on by default).'
),
booleanParam(
name: 'FIREFOX_TESTS',
defaultValue: false,
description: 'Run E2E tests in Firefox (off by default; enable when needed).'
),
booleanParam(
name: 'WEBKIT_TESTS',
defaultValue: false,
description: 'Run E2E tests in WebKit (off by default; enable when needed).'
),
booleanParam(
name: 'EDGE_TESTS',
defaultValue: false,
description: 'Run E2E tests in Microsoft Edge (off by default; enable when needed).'
),
booleanParam(
name: 'MOBILE_ANDROID_TESTS',
defaultValue: false,
description: 'Run E2E tests on the Android (Pixel 5) profile (off by default; enable when needed).'
),
booleanParam(
name: 'MOBILE_IOS_TESTS',
defaultValue: false,
description: 'Run E2E tests on the iOS (iPhone 12) WebKit profile (off by default; enable when needed).'
),
booleanParam(
name: 'MOBILE_IPAD_TESTS',
defaultValue: false,
description: 'Run E2E tests on the iPad (iPad Pro 11) WebKit profile (off by default; enable when needed).'
),
])
])
@Library("Infrastructure")
def type = "java"
def product = "pcs"
def component = "api"
static Map<String, Object> secret(String secretName, String envVariable) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
envVariable: envVariable
]
}
def secrets = [
'pcs-${env}': [
secret('pcs-api-idam-secret', 'PCS_API_IDAM_SECRET'),
secret('idam-testing-support-url', 'IDAM_TESTING_SUPPORT_URL'),
secret('idam-system-user-name', 'IDAM_SYSTEM_USERNAME'),
secret('idam-system-user-password', 'IDAM_SYSTEM_USER_PASSWORD'),
secret('idam-pcs-user-password', 'IDAM_PCS_USER_PASSWORD'),
secret('pcs-solicitor-automation-uid', 'PCS_SOLICITOR_AUTOMATION_UID'),
secret('pcs-prd-admin-username', 'PCS_PRD_ADMIN_USERNAME'),
secret('pcs-prd-admin-password', 'PCS_PRD_ADMIN_PASSWORD')
]
]
withNightlyPipeline(type, product, component) {
validateInputs()
enableSlackNotifications('#pcs-tech')
loadVaultSecrets(secrets)
handleEnvironmentSetting()
enableFortifyScan()
afterAlways('fortify-scan') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/Fortify Scan/**/*'
runE2eMatrix()
}
}
def validateInputs() {
if (!getE2eMatrix().any { params[it.flag] }) {
error('E2E matrix: enable at least one browser/device option (e.g. CHROME_TESTS).')
}
}
def handleEnvironmentSetting() {
env.E2E_TEST_SCOPE = '@nightly'
env.ENVIRONMENT = 'aat'
env.MANAGE_CASE_BASE_URL = 'https://manage-case.aat.platform.hmcts.net'
env.DATA_STORE_URL_BASE = 'http://ccd-data-store-api-aat.service.core-compute-aat.internal'
}
def getE2eMatrix() {
[
[flag: 'CHROME_TESTS', suite: 'chrome', browser: 'Chrome', label: 'Desktop Chrome'],
[flag: 'FIREFOX_TESTS', suite: 'firefox', browser: 'Firefox', label: 'Desktop Firefox'],
[flag: 'WEBKIT_TESTS', suite: 'webkit', browser: 'Safari', label: 'Desktop Safari (WebKit)'],
[flag: 'EDGE_TESTS', suite: 'edge', browser: 'Edge', label: 'Desktop Edge'],
[flag: 'MOBILE_ANDROID_TESTS', suite: 'mobile-android', browser: 'MobileAndroid', label: 'Mobile Android (Pixel 5)'],
[flag: 'MOBILE_IOS_TESTS', suite: 'mobile-ios', browser: 'MobileIos', label: 'Mobile iOS (WebKit)'],
[flag: 'MOBILE_IPAD_TESTS', suite: 'mobile-ipad', browser: 'MobileIpad', label: 'Mobile iPad (WebKit)'],
]
}
def runE2eMatrix() {
def gradleBuilder = new uk.gov.hmcts.contino.GradleBuilder(this, product)
getE2eMatrix().findAll { params[it.flag] }.each { row ->
runE2eStage(gradleBuilder, row)
}
}
def runE2eStage(gradleBuilder, Map row) {
stage("E2E - ${row.label}") {
node {
checkout scm
sh 'rm -rf e2e-output allure-report src/e2eTest/allure-results src/e2eTest/.auth/storage-state.json || true'
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
withEnv(["E2E_SUITE=${row.suite}"]) {
gradleBuilder.gradle('runE2eTests')
}
}
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'e2e-output',
reportFiles: 'index.html',
reportName: "Full ${row.browser} E2E Test Report"
])
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/e2e-output/**/*'
sendAllureReportToSlack(row.label, "Full_20${row.browser}_20E2E_20Test_20Report/")
}
}
}
def sendAllureReportToSlack(String stageLabel, String reportSuffix) {
env.E2E_BROWSER = stageLabel
env.ALLURE_REPORT_PATH_SUFFIX = reportSuffix
env.E2E_SERVICE_NAME = 'pcs-api'
env.E2E_PIPELINE_TYPE = 'nightly'
def msg = sh(
script: 'cd src/e2eTest && E2E_SERVICE_NAME=pcs-api E2E_PIPELINE_TYPE=nightly ./node_modules/.bin/tsx ./scripts/allure-slack-notifier.ts --print-only || true',
returnStdout: true
).trim()
if (!msg) {
msg = "E2E Test Results — Build #${env.BUILD_NUMBER}\n*Service:* pcs-api | *Pipeline:* nightly\n\nAllure report not available – check build logs.\n*Allure report:* ${env.BUILD_URL}${reportSuffix}"
}
try {
slackSend(channel: '#hdp-qa-e2e-test-results', message: msg)
echo "E2E Slack notification sent to #hdp-qa-e2e-test-results (${stageLabel})"
} catch (Exception e) {
echo "WARNING: Failed to send E2E Slack notification: ${e.message}. Check Jenkins Slack plugin and channel access."
}
}