-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile_CNP
More file actions
145 lines (122 loc) · 4.58 KB
/
Jenkinsfile_CNP
File metadata and controls
145 lines (122 loc) · 4.58 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
#!groovy
properties(
[
[
$class : 'GithubProjectProperty',
projectUrlStr: 'https://github.com/hmcts/rd-location-ref-data-load'
],
pipelineTriggers([[$class: 'GitHubPushTrigger']])
]
)
@Library("Infrastructure")
import uk.gov.hmcts.contino.DockerImage
import uk.gov.hmcts.contino.GradleBuilder
import uk.gov.hmcts.contino.Kubectl
import uk.gov.hmcts.pipeline.TeamConfig
def type = "java"
def product = "rd"
def component = "location-ref-data-load"
static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
[$class : 'AzureKeyVaultSecret',
secretType : 'Secret',
name : secretName,
version : '',
envVariable: envVar
]
}
def vaultOverrides = [
'preview' : 'aat',
'spreview': 'saat'
]
def secrets = [
'rd-${env}': [
secret('ACCOUNT-KEY-PREVIEW', 'ACCOUNT_KEY_PREVIEW'),
secret('rd-location-storage-account-name', 'ACCOUNT_NAME'),
secret('rd-location-storage-account-primary-key', 'ACCOUNT_KEY')
]
]
// Configure branches to sync with master branch
def branchesToSync = ['ithc', 'perftest']
// Var for testcontainers.org
env.TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX = "hmctsprod.azurecr.io/imported/"
GradleBuilder builder = new GradleBuilder(this, product)
withPipeline(type, product, component) {
overrideVaultEnvironments(vaultOverrides)
loadVaultSecrets(secrets)
env.CONTAINER_NAME = "lrd-ref-data"
onMaster {
enableSlackNotifications('#rd-master-builds')
env.execution_environment = "aat"
}
onPR {
enableSlackNotifications('#rd-master-builds')
env.execution_environment = "preview"
}
enableAksStagingDeployment()
disableLegacyDeploymentOnAAT()
disableLegacyDeployment()
nonServiceApp()
before('functionalTest:preview') {
env.TEST_URL = "http://rd-location-ref-data-load-preview.preview.hmcts.platform.net"
}
before('functionalTest:aat') {
env.TEST_URL = "http://rd-location-ref-data-load-aat.aat.hmcts.platform.net"
}
before('smoketest:preview') {
env.TEST_URL = "http://rd-location-ref-data-load-preview.preview.platform.hmcts.net"
}
before('smoketest:aat') {
env.TEST_URL = "http://rd-location-ref-data-load-aat.aat.platform.hmcts.net"
}
// Sync demo and perftest with master branch
syncBranchesWithMaster(branchesToSync)
afterSuccess('functionalTest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/functional/**/*'
}
afterSuccess('functionalTest:aat') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/functional/**/*'
}
afterSuccess('akschartsinstall') {
def sleepTime = (env.BRANCH_NAME.startsWith("PR")) ? '210s' : '120s'
sh "sleep ${sleepTime}"
if (env.BRANCH_NAME.startsWith("PR")) {
withAksClient('nonprod', product) {
def dockerImage = new DockerImage(product, component, null, env.BRANCH_NAME, env.GIT_COMMIT, env.LAST_COMMIT_TIMESTAMP)
def subscription = env.SUBSCRIPTION_NAME
def aksServiceName = dockerImage.getAksServiceName().toLowerCase()
def namespace = new TeamConfig(this).getNameSpace(product)
def kubectl = new Kubectl(this, subscription, namespace)
kubectl.login()
env.BLOB_ACCOUNT_NAME = kubectl.getSecret("storage-account-${aksServiceName}-blobstorage", namespace, "{.data.storage_account_name}")
env.BLOB_ACCOUNT_KEY = kubectl.getSecret("storage-secret-${aksServiceName}-blobstorage", namespace, "{.data.accessKey}")
}
}
try {
builder.gradle('functional')
} finally {
junit '**/test-results/**/*.xml'
junit 'build/test-results/functional/**/*.xml'
archiveArtifacts 'build/reports/tests/functional/index.html'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/functional",
reportFiles : "index.html",
reportName : "LRD Functional Test Report"
]
}
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/functional/**/*'
}
afterSuccess('sonarscan') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/**/*'
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/tests/test",
reportFiles : "index.html",
reportName : "Unit Tests Report"
]
}
}