-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile_nightly
121 lines (103 loc) · 4.45 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
#!groovy
properties([
pipelineTriggers([cron('H 07 * * 1-5')]), // scheduling to trigger jenkins job
parameters([
string(name: 'ENVIRONMENT', defaultValue: 'aat', description: 'Environment to test'),
string(name: 'URL_TO_TEST', defaultValue: 'http://rd-user-profile-api-aat.service.core-compute-aat.internal', description: 'The URL you want to run these tests against'),
string(name: 'SecurityRules',
defaultValue: 'http://raw.githubusercontent.com/hmcts/security-test-rules/master/conf/security-rules.conf',
description: 'The URL you want to run these tests against'),
])
])
@Library("Infrastructure")
def type = "java"
def product = "rd"
def component = "user-profile-api"
def secrets = [
's2s-${env}': [
secret('microservicekey-rd-user-profile-api', 'USER_PROFILE_API_S2S_SECRET')
],
'rd-${env}': [
secret('user-profile-api-POSTGRES-HOST', 'FUNC_DATABASE_HOST'),
secret('user-profile-api-POSTGRES-PASS', 'FUNC_DATABASE_PASS'),
secret('user-profile-api-POSTGRES-USER', 'FUNC_DATABASE_USER'),
secret('user-profile-api-POSTGRES-DATABASE', 'FUNC_DATABASE_NAME'),
secret('user-profile-api-POSTGRES-PORT', 'FUNC_DATABASE_PORT'),
secret('OAUTH2-CLIENT-SECRET', 'OAUTH2_CLIENT_SECRET'),
secret('OAUTH2-CLIENT-AUTH', 'OAUTH2_CLIENT_AUTH'),
secret('OAUTH2-CLIENT-ID', 'OAUTH2_CLIENT_ID'),
secret('LD-SDK-KEY', 'LD_SDK_KEY')
]
]
static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
version : '',
envVariable: envVar
]
}
def vaultOverrides = [
'preview' : 'aat',
'spreview': 'saat'
]
import uk.gov.hmcts.contino.AppPipelineConfig
def subscription = "nonprod"
def config = new AppPipelineConfig()
config.vaultSecrets = secrets
withNightlyPipeline(type, product, component) {
env.TEST_URL = params.URL_TO_TEST
env.S2S_URL_FOR_TESTS = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.Rules = params.SecurityRules
env.execution_environment = "aat"
// Var for testcontainers.org
env.TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX = "hmctspublic.azurecr.io/imported/"
overrideVaultEnvironments(vaultOverrides)
loadVaultSecrets(secrets)
enableMutationTest()
enableFullFunctionalTest()
enableSecurityScan()
enableFortifyScan()
afterAlways('fullFunctionalTest') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/site/serenity/**/*'
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "target/site/serenity/",
reportFiles : "index.html",
reportName : "Functional Tests Report"
]
print "calling delete script for nightly"
withSubscription(subscription) {
withTeamSecrets(config, params.ENVIRONMENT) {
deleteFunctionalDbData()
}
}
print "done delete script for nightly"
}
afterAlways('fortify-scan') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/Fortify Scan/**/*'
}
afterAlways('mutationTest') {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/pitest",
reportFiles : "index.html",
reportName : "Mutation Test Report"
]
}
}
def deleteFunctionalDbData() {
withDocker('hmctspublic.azurecr.io/imported/jbergknoff/postgresql-client', "--entrypoint='' -e PGPASSWORD=${FUNC_DATABASE_PASS} -v ${WORKSPACE}/deletescript/:/deletescript") {
sh "chmod +x /deletescript/delete-functional-data.sh"
sh "/deletescript/delete-functional-data.sh \
${FUNC_DATABASE_USER} \
${FUNC_DATABASE_NAME} \
${FUNC_DATABASE_HOST} \
${FUNC_DATABASE_PORT}"
}
}