-
Notifications
You must be signed in to change notification settings - Fork 25
/
Jenkinsfile
193 lines (189 loc) · 6.99 KB
/
Jenkinsfile
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
pipeline {
options {
disableConcurrentBuilds()
}
agent any
tools {
maven 'maven-3.8.7'
jdk 'jdk11'
}
triggers {
// timer trigger for "nightly build" on main branch
cron( env.BRANCH_NAME.equals('main') ? 'H H(0-3) * * 1-5' : '')
}
environment {
// variables for SystemTest stages (integration tests)
STAGING_DIR = "${WORKSPACE}/wit-system-test-files"
DB_IMAGE = "${WKT_OCIR_HOST}/${WKT_TENANCY}/database/enterprise:12.2.0.1-slim"
JRE_IMAGE = "${WKT_OCIR_HOST}/${WKT_TENANCY}/java/serverjre:8"
}
stages {
stage ('Environment') {
steps {
sh '''
echo "PATH = ${PATH}"
echo "M2_HOME = ${M2_HOME}"
mvn --version
'''
}
}
stage ('Build') {
steps {
withMaven(globalMavenSettingsConfig: 'wkt-maven-settings-xml', publisherStrategy: 'EXPLICIT') {
sh 'mvn -B -DskipTests -DskipITs clean install'
}
}
}
stage ('Unit Tests') {
when {
not { changelog '\\[skip-ci\\].*' }
}
steps {
withMaven(globalMavenSettingsConfig: 'wkt-maven-settings-xml', publisherStrategy: 'EXPLICIT') {
sh 'mvn -B test'
}
}
post {
always {
junit 'imagetool/target/surefire-reports/*.xml'
}
}
}
// stage ('Sonar Analysis') {
// when {
// anyOf {
// changeRequest()
// branch "main"
// }
// }
// tools {
// maven 'maven-3.8.7'
// jdk 'jdk11'
// }
// steps {
// withSonarQubeEnv('SonarCloud') {
// withCredentials([string(credentialsId: 'encj_github_token', variable: 'GITHUB_TOKEN')]) {
// runSonarScanner()
// }
// }
// }
// }
stage ('Download System Test Files') {
when {
anyOf {
changeRequest target: 'main'
triggeredBy 'TimerTrigger'
changelog '\\[full-mats\\].*'
}
}
steps {
sh '''
rm -rf ${STAGING_DIR}
mkdir ${STAGING_DIR}
oci os object bulk-download --namespace devweblogic --bucket-name wit-system-test-files --config-file=/dev/null --auth=instance_principal --download-dir ${STAGING_DIR}
'''
}
}
stage ('SystemTest Gate') {
when {
allOf {
changeRequest target: 'main'
not { changelog '\\[skip-ci\\].*' }
not { changelog '\\[full-mats\\].*' }
}
}
steps {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'wkt-otn-credential', passwordVariable: 'ORACLE_SUPPORT_PASSWORD', usernameVariable: 'ORACLE_SUPPORT_USERNAME']]) {
withMaven(globalMavenSettingsConfig: 'wkt-maven-settings-xml', publisherStrategy: 'EXPLICIT') {
sh '''
cd tests
mvn -B clean verify -Dtest.groups=gate -DskipITs=false
'''
}
}
}
post {
always {
junit 'tests/target/failsafe-reports/*.xml'
}
failure {
archiveArtifacts artifacts: 'tests/target/logs/*.*', onlyIfSuccessful: 'false'
}
}
}
stage ('SystemTest Full') {
when {
anyOf {
triggeredBy 'TimerTrigger'
changelog '\\[full-mats\\].*'
}
}
steps {
script {
docker.image("${env.DB_IMAGE}").pull()
docker.image("${env.JRE_IMAGE}").pull()
}
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'wkt-otn-credential', passwordVariable: 'ORACLE_SUPPORT_PASSWORD', usernameVariable: 'ORACLE_SUPPORT_USERNAME']]) {
withMaven(globalMavenSettingsConfig: 'wkt-maven-settings-xml', publisherStrategy: 'EXPLICIT') {
sh '''
cd tests
mvn -B clean verify -Dtest.groups=gate,nightly -DskipITs=false
'''
}
}
}
post {
always {
junit 'tests/target/failsafe-reports/*.xml'
}
failure {
// save logs for debugging test failures
archiveArtifacts artifacts: 'tests/target/logs/*.*', onlyIfSuccessful: 'false'
// notify staff when nightly builds fail
slackSend channel: '#wkt-build-failure-notifications', botUser: false, color: 'danger',
message: "Build failed. WebLogic Image Tool: <${env.BUILD_URL}|${env.JOB_NAME}:${env.BUILD_NUMBER}>"
}
}
}
stage ('Save Nightly Installer') {
when {
triggeredBy 'TimerTrigger'
branch "main"
}
steps {
sh '''
oci os object put --namespace=${WKT_TENANCY} --bucket-name=wko-system-test-files --config-file=/dev/null --auth=instance_principal --force --file=installer/target/imagetool.zip --name=imagetool-main.zip
'''
}
}
stage ('Sync') {
when {
branch 'main'
not { triggeredBy 'TimerTrigger' }
}
steps {
build job: "wkt-sync",
parameters: [ string(name: 'REPOSITORY', value: 'weblogic-image-tool') ],
wait: true
}
}
}
}
//void runSonarScanner() {
// def changeUrl = env.GIT_URL.split("/")
// def org = changeUrl[3]
// def repo = changeUrl[4].substring(0, changeUrl[4].length() - 4)
// if (env.CHANGE_ID != null) {
// sh "mvn -B sonar:sonar \
// -Dsonar.projectKey=${org}_${repo} \
// -Dsonar.pullrequest.provider=GitHub \
// -Dsonar.pullrequest.github.repository=${org}/${repo} \
// -Dsonar.pullrequest.key=${env.CHANGE_ID} \
// -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} \
// -Dsonar.pullrequest.base=${env.CHANGE_TARGET}"
// } else {
// sh "mvn -B sonar:sonar \
// -Dsonar.projectKey=${org}_${repo} \
// -Dsonar.branch.name=${env.BRANCH_NAME}"
// }
//}