-
Notifications
You must be signed in to change notification settings - Fork 10
/
Jenkinsfile_nightly
165 lines (150 loc) · 6.34 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
#!groovy
properties([
pipelineTriggers([cron('H 07 * * 1-5')]),
parameters([
string(name: 'ENVIRONMENT', defaultValue: 'aat', description: 'Environment to test'),
string(name: 'PLAYWRIGHT_WORKERS', defaultValue: '5', description: 'Number of workers for playwright'),
string(name: 'PLAYWRIGHT_RETRIES', defaultValue: '2', description: 'Number of times playwright will retry tests'),
string(name: 'PLAYWRIGHT_RUN_ACCESSIBILITY_TESTS', defaultValue: 'false', description: 'Runs accessibility tests for playwright during test execution'),
string(name: 'PLAYWRIGHT_RUN_SETUP', defaultValue: 'true', description: 'Runs setup projects before functional test suite'),
string(name: 'FRONTEND_URL', defaultValue: 'https://manage-case.aat.platform.hmcts.net',
description: 'The URL you want to run the full functional tests against'),
string(name: 'IDAM_WEB_URL', defaultValue: 'https://idam-web.aat.platform.hmcts.net', description: 'The URL of idam web'),
string(name: 'IDAM_API_URL', defaultValue: 'https://idam-api.aat.platform.hmcts.net',
description: 'The URL of idam api'),
string(name: 'DM_STORE_URL', defaultValue: 'http://dm-store-aat.service.core-compute-aat.internal',
description: 'The URL of dm store'),
string(name: 'SERVICE_AUTH_PROVIDER_API_BASE_URL', defaultValue: 'http://rpe-service-auth-provider-aat.service.core-compute-aat.internal',
description: 'The URL of service auth provider'),
string(name: 'CCD_DATA_STORE_URL', defaultValue: 'http://ccd-data-store-api-aat.service.core-compute-aat.internal',
description: 'The URL of ccd data store'),
string(name: 'CIVIL_SERVICE_URL', defaultValue: 'http://civil-service-aat.service.core-compute-aat.internal',
description: 'The URL of civil service'),
string(name: 'WAIT_FOR_TIMEOUT_MS',
defaultValue: '120000',
description: 'Functional tests waitForTimeout value'),
string(name: 'SECURITY_RULES',
defaultValue: 'https://raw.githubusercontent.com/hmcts/security-test-rules/master/conf/security-rules.conf',
description: 'The security rules to use')
])
])
@Library("Infrastructure")
def type = "nodejs"
def product = "civil"
def component = "ccd"
def yarnBuilder = new uk.gov.hmcts.contino.YarnBuilder(this)
static Map<String, Object> secret(String secretName, String envVariable) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
envVariable: envVariable
]
}
void publishBootstrapReport() {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'playwright-allure-bootstrap-report',
reportFiles: 'index.html',
reportName: 'Playwright Allure Bootstrap Report'
])
}
void publishFunctionalReport() {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'playwright-allure-functional-report',
reportFiles: 'index.html',
reportName: 'Playwright Allure Functional Report'
])
}
def secrets = [
'civil-${env}': [
secret('microservicekey-civil-service', 'S2S_SECRET'),
secret('default-password', 'DEFAULT_PASSWORD'),
secret('judge-default-password', 'JUDGE_DEFAULT_PASSWORD'),
secret('iac-default-password', 'IAC_DEFAULT_PASSWORD'),
secret('system-update-user-password', 'SYSTEM_USER_PASSWORD')
]
]
withNightlyPipeline(type, product, component) {
env.ENVIRONMENT=params.ENVIRONMENT
env.PLAYWRIGHT_WORKERS=params.PLAYWRIGHT_WORKERS
env.PLAYWRIGHT_RETRIES=params.PLAYWRIGHT_RETRIES
env.PLAYWRIGHT_RUN_ACCESSIBILITY_TESTS=params.PLAYWRIGHT_RUN_ACCESSIBILITY_TESTS
env.PLAYWRIGHT_RUN_SETUP=params.PLAYWRIGHT_RUN_SETUP
env.PLAYWRIGHT_UNASSIGN_CASES = true
env.URL=params.FRONTEND_URL
env.DM_STORE_URL=params.DM_STORE_URL
env.IDAM_WEB_URL=params.IDAM_WEB_URL
env.IDAM_API_URL=params.IDAM_API_URL
env.SERVICE_AUTH_PROVIDER_API_BASE_URL = params.SERVICE_AUTH_PROVIDER_API_BASE_URL
env.CCD_DATA_STORE_URL = params.CCD_DATA_STORE_URL
env.CIVIL_SERVICE_URL = params.CIVIL_SERVICE_URL
env.WAIT_FOR_TIMEOUT_MS = params.WAIT_FOR_TIMEOUT_MS
env.URL_FOR_SECURITY_SCAN = params.CIVIL_SERVICE_URL
env.CCD_UI_TESTS = true
loadVaultSecrets(secrets)
boolean playwrightSetupPassed=true
boolean flowInterrupted = false
afterAlways('DependencyCheckNightly') {
stage('Playwright test setup') {
try {
yarnBuilder.yarn('test:playwright-setup:install')
if(env.PLAYWRIGHT_RUN_SETUP) {
yarnBuilder.yarn('test:playwright-e2e-setup:ci')
}
} catch (Exception error) {
if(error instanceof org.jenkinsci.plugins.workflow.steps.FlowInterruptedException) {
flowInterrupted = true
}
if(env.PLAYWRIGHT_RUN_SETUP) {
playwrightSetupPassed=false
}
unstable(message: "${STAGE_NAME} is unstable: " + error.toString())
} finally {
if(env.PLAYWRIGHT_RUN_SETUP) {
yarnBuilder.yarn('test:playwright-bootstrap:generate-report')
}
}
}
stage('Playwright full functional test') {
try {
if(flowInterrupted) {
throw new org.jenkinsci.plugins.workflow.steps.FlowInterruptedException()
}
if(playwrightSetupPassed) {
yarnBuilder.yarn('test:playwright-e2e-nightly:ci')
}
} catch (Exception error) {
if(error instanceof org.jenkinsci.plugins.workflow.steps.FlowInterruptedException) {
flowInterrupted = true
}
unstable(message: "${STAGE_NAME} is unstable: " + error.toString())
} finally {
if(playwrightSetupPassed) {
yarnBuilder.yarn('test:playwright-functional:generate-report')
publishFunctionalReport()
}
}
}
if(env.PLAYWRIGHT_RUN_SETUP) {
stage('Playwright test teardown') {
try {
yarnBuilder.yarn('test:playwright-e2e-teardown:ci')
} catch (Exception error) {
unstable(message: "${STAGE_NAME} is unstable: " + error.toString())
} finally {
yarnBuilder.yarn('test:playwright-bootstrap:generate-report')
publishBootstrapReport()
}
}
}
}
enableFullFunctionalTest(200)
afterAlways('fullFunctionalTest') {
archiveArtifacts allowEmptyArchive: true, artifacts: 'test-results/functional/**/*'
}
}