-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathJenkinsfile_CNP
135 lines (119 loc) · 4.73 KB
/
Jenkinsfile_CNP
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
#!groovy
@Library("Infrastructure") _
import uk.gov.hmcts.contino.GithubAPI
import uk.gov.hmcts.contino.AppPipelineDsl
def yarnBuilder = new uk.gov.hmcts.contino.YarnBuilder(this)
String product = "probate"
String component = "frontend"
def checkForNightlyLabel(branch_name) {
return new GithubAPI(this).getLabelsbyPattern(branch_name, "nightly").contains("nightly")
}
def checkForNightlyWithoutWelshTestsLabel(branch_name) {
return new GithubAPI(this).getLabelsbyPattern(branch_name, "nightly-without-welsh-tests").contains("nightly-without-welsh-tests")
}
def secrets = [
'probate-${env}': [
secret('testIdamBaseUrl', 'IDAM_API_URL'),
secret('testIdamLoginUrl', 'IDAM_LOGIN_URL'),
secret('testUseIdam', 'USE_IDAM'),
secret('testInviteIdListUrl', 'INVITE_ID_LIST_URL'),
secret('testPinUrl', 'PIN_URL'),
secret('testInvitationUrl', 'INVITATION_URL'),
secret('testIdamAddUserUrl', 'IDAM_ADD_USER_URL'),
secret('testIdamRole', 'IDAM_CITIZEN_ROLE'),
secret('testIdamUserGroup', 'IDAM_USER_GROUP'),
secret('testCitizenDomain', 'CITIZEN_EMAIL_DOMAIN'),
secret('testEnvEmailAddress', 'TEST_EMAIL_ADDRESS'),
secret('testEnvMobileNumber', 'TEST_MOBILE_NUMBER'),
secret('testTerms', 'TERMS_AND_CONDITIONS'),
secret('testSurvey', 'SURVEY'),
secret('testsurveyEndOfApplication', 'SURVEY_END_OF_APPLICATION'),
secret('testPostcodeServiceUrl', 'POSTCODE_SERVICE_URL'),
secret('testPostCodeAddressToken2', 'ADDRESS_TOKEN'),
secret('testRunE2ETest', 'RUN_E2E_TEST'),
secret('testValidationServiceUrl', 'VALIDATION_SERVICE_URL'),
secret('launchdarkly-key', 'LAUNCHDARKLY_KEY'),
secret('launchdarklyUserkeyFrontend', 'LAUNCHDARKLY_USER_KEY'),
secret('webchat-avaya-url', 'WEBCHAT_AVAYA_URL'),
secret('webchat-avaya-client-url', 'WEBCHAT_AVAYA_CLIENT_URL'),
secret('webchat-avaya-service', 'WEBCHAT_AVAYA_SERVICE'),
secret('AppInsightsInstrumentationKey', 'APPINSIGHTS_INSTRUMENTATIONKEY')
]
]
static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
version : '',
envVariable: envVar
]
}
// Configure branches to sync with master branch
def branchesToSync = ['demo', 'ithc', 'perftest']
withPipeline("nodejs", product, component) {
/* afterCheckout {
onMaster {
try {
sh """
git fetch origin demo:demo
git push --force origin HEAD:demo
"""
} catch (err) {
notifyBuildEvent channel: notificationsChannel, color: 'warning', message: 'Failed to update demo branch'
}
}
} */
// afterSuccess('test') {
// if (env.CHANGE_BRANCH || env.BRANCH_NAME == 'master') {
// env.PACT_BRANCH_NAME = env.CHANGE_BRANCH
// env.PACT_BROKER_URL = "https://pact-broker.platform.hmcts.net"
// if (env.BRANCH_NAME == 'master') {
// env.PACT_BRANCH_NAME = 'master'
// }
// env.PACT_BROKER_VERSION = sh(returnStdout: true, script: 'git rev-parse --verify --short HEAD')
// sh 'printenv'
// sh 'yarn test-pact'
// sh 'yarn publish-pact'
// sh 'curl -LO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.63.0/pact-1.63.0-linux-x86_64.tar.gz'
// sh 'tar xzf pact-1.63.0-linux-x86_64.tar.gz'
// dir('pact/bin') {
// sh './pact-broker can-i-deploy --retry-while-unknown=12 --retry-interval=10 -a probate_frontend -b ${PACT_BROKER_URL} -e ${PACT_BROKER_VERSION}'
// }
// }
// }
/*
before('buildinfra:prod') {
error 'Deliberately breaking pipeline to prevent prod deployment'
}
*/
enableAksStagingDeployment()
disableLegacyDeployment()
loadVaultSecrets(secrets)
enableSlackNotifications('#probate-jenkins')
syncBranchesWithMaster(branchesToSync)
afterSuccess('functionalTest:preview') {
publishHTML target: [
reportDir : "functional-output/",
reportFiles : "mochawesome.html",
reportName : "Preview Functional Tests",
alwaysLinkToLastBuild: true
]
if (checkForNightlyWithoutWelshTestsLabel(env.BRANCH_NAME)) {
env.DONT_TEST_WELSH = true
yarnBuilder.yarn('test:fullfunctional-pr');
} else if (checkForNightlyLabel(env.BRANCH_NAME)) {
yarnBuilder.yarn('test:fullfunctional-pr');
}
}
afterSuccess('functionalTest:aat') {
publishHTML target: [
reportDir : "functional-output/",
reportFiles : "mochawesome.html",
reportName : "AAT Functional Tests",
alwaysLinkToLastBuild: true
]
}
enablePactAs([
AppPipelineDsl.PactRoles.CONSUMER
])
}