generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile_CNP
120 lines (104 loc) · 3.8 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
#!groovy
@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 = "commondata-dataload"
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-commondata-storage-account-name', 'ACCOUNT_NAME'),
secret('rd-commondata-storage-account-primary-key', 'ACCOUNT_KEY')
]
]
// Configure branches to sync with master branch
def branchesToSync = ['demo', 'ithc', 'perftest']
// Var for testcontainers.org
env.TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX = "hmctspublic.azurecr.io/imported/"
GradleBuilder builder = new GradleBuilder(this, product)
withPipeline(type, product, component) {
overrideVaultEnvironments(vaultOverrides)
loadVaultSecrets(secrets)
env.CONTAINER_NAME = "rd-common-data"
onMaster {
env.execution_environment = "aat"
}
onPR {
env.execution_environment = "preview"
}
enableAksStagingDeployment()
disableLegacyDeploymentOnAAT()
disableLegacyDeployment()
nonServiceApp()
syncBranchesWithMaster(branchesToSync)
before('functionalTest:preview') {
env.TEST_URL = "http://rd-commondata-dataload-preview.preview.platform.hmcts.net"
}
before('functionalTest:aat') {
env.TEST_URL = "http://rd-commondata-dataload-aat.aat.platform.hmcts.net"
}
afterSuccess('functionalTest:preview') {
steps.archiveArtifacts allowEmptyArchive: true
}
afterSuccess('functionalTest:aat') {
steps.archiveArtifacts allowEmptyArchive: true
}
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 : "Common Data Functional Test Report"
]
}
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/site/serenity/**/*'
}
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"
]
}
}