-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitbucket-pipelines.yml
319 lines (316 loc) · 11.8 KB
/
bitbucket-pipelines.yml
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
image:
name: vlaamseoverheid-magda-docker-public.jfrog.io/magda/magda-base-pipeline:jdk21-latest
username: $ARTIFACTORY_USER
password: $ARTIFACTORY_PASSWORD
definitions:
steps:
- step: &deploy
name: Deploy to ...
deployment: PLACEHOLDER
caches:
- maven
script:
- export INFRA_REPO='magdamock.service-infra'
- export IFS=' '
# Allow overwriting applications in deployments
- >
if [[ "$APPS" == "" ]]; then
export APPS='magdamock-service'
fi
- echo $NAMESPACE > target/namespace # Necessary for passing namespace to the next steps
- chmod +x deploy-with-argocd.sh
- ./deploy-with-argocd.sh
artifacts:
- target/namespace
- step: &build
name: Building
caches:
- maven
script:
- export TESTCONTAINERS_RYUK_DISABLED=true
- export MAVEN_OPTS="-Xmx1024m"
- mvn -B -U clean verify -s .m2/settings.xml
artifacts:
- "**/*.jar"
- step: &release
name: Release
caches:
- maven
script:
- export TESTCONTAINERS_RYUK_DISABLED=true
- /bin/bash ./release-application.sh
- step: &dockerRebuildFromTag
name: Rebuild Docker from tag
caches:
- maven
- docker
script:
- export VERSION=$rebuild_git_tag
# Checkout
- source "commons.sh"
- prepare_git
- git checkout $VERSION
- mvn -B package io.fabric8:docker-maven-plugin:0.31.0:push -s .m2/settings.xml -Pdocker-release
- step: &newmanTest
name: Newman integration test
image: postman/newman
script:
- export NAMESPACE=`cat target/namespace`
# No need to proceed if there is no test config found
- >
if [[ ! -d "newman-test/" ]]; then
echo "No newman-test dir found, so not running Postman tests."
exit 0
fi
- npm install -g newman-reporter-junit5
- apk add curl jq
- sh ./wait-for-deploy.sh
- newman run $POSTMAN_URL -e newman-test/$NAMESPACE-config.json -r junit5,cli --reporter-junit5-export test-results/newman-test-results.xml
- step: &sigridPublish
image: softwareimprovementgroup/sigridci
name: Publish to Sigrid
script:
- git config --global --add safe.directory /opt/atlassian/pipelines/agent/build
- timeout 10m sigridci.py --customer $SIGRID_CI_ACCOUNT --system $(echo $BITBUCKET_REPO_FULL_NAME | cut -d'/' -f 2 | cut -c 1-45| sed -e "s/\./-/g") --source . --publishonly --include-history
- step: &sigridCI
image: softwareimprovementgroup/sigridci
name: Sigrid CI
script:
- git config --global --add safe.directory /opt/atlassian/pipelines/agent/build
- timeout 10m sigridci.py --customer $SIGRID_CI_ACCOUNT --system $(echo $BITBUCKET_REPO_FULL_NAME | cut -d'/' -f 2 | cut -c 1-45| sed -e "s/\./-/g") --source .
- step: &githubMirror
name: Sync to Github
clone:
enabled: false
script:
- git clone --bare [email protected]:vlaamseoverheid/magdamock.service.git
- cd magdamock.service.git
- git push --mirror [email protected]:Informatievlaanderen/MAGDA-Mock.git
clone:
depth: full
pipelines:
branches:
master:
- parallel:
steps:
- step:
name: Check
caches:
- maven
script:
# Only run for released version
- mvn -B -s .m2/settings.xml org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce -Drules=requireReleaseVersion
- mkdir -p target
- mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout > target/pom_version
artifacts:
- target/pom_version
- step:
<<: *sigridPublish
- step:
<<: *deploy
name: Deploy release to TST
deployment: TST_SOLID
- step:
<<: *newmanTest
name: Verify deploy to TST
- step:
<<: *deploy
name: Deploy release to TNI
deployment: TNI_SOLID
- step:
<<: *newmanTest
name: Verify deploy to TNI
- step:
<<: *deploy
name: Deploy release to PRD
trigger: manual
deployment: PRD_SOLID
develop:
- parallel:
steps:
- step:
name: Maven
caches:
- maven
- docker
script:
- export TESTCONTAINERS_RYUK_DISABLED=true
- export MAVEN_OPTS="-Xmx1024m"
- mvn -B -U clean deploy sonar:sonar -s .m2/settings.xml -Dbuild=bitbucket -Pdocker -Dsonar.host.url=${SONAR_HOST} -Dsonar.projectKey=${SONAR_PROJECT} -Dsonar.login=${SONAR_USERNAME} -Dsonar.password=${SONAR_PASSWORD}
- mkdir -p target
- mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout > target/pom_version
artifacts:
- "**/*.jar"
- target/pom_version
- step:
<<: *sigridPublish
- step:
<<: *deploy
name: Deploy to BETA
deployment: DEV_SOLID
- step:
<<: *newmanTest
name: Verify deploy to BETA
hotfix/*:
- step:
name: Maven
caches:
- maven
- docker
script:
- export TESTCONTAINERS_RYUK_DISABLED=true
- export MAVEN_OPTS="-Xmx1024m"
- mvn -B -U clean deploy sonar:sonar -s .m2/settings.xml -Dbuild=bitbucket -Pdocker -Dsonar.host.url=${SONAR_HOST} -Dsonar.projectKey=${SONAR_PROJECT} -Dsonar.login=${SONAR_USERNAME} -Dsonar.password=${SONAR_PASSWORD} -Dsonar.branch.target=master -Dsonar.branch.name="$BITBUCKET_BRANCH"
- mkdir -p target
- mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout > target/pom_version
artifacts:
- "**/*.jar"
- target/pom_version
- step:
<<: *deploy
name: Deploy to BETA
deployment: DEV_SOLID
- step:
<<: *newmanTest
name: Verify deploy to BETA
- step:
<<: *deploy
name: Deploy to TST
deployment: TST_SOLID
- step:
<<: *newmanTest
name: Verify deploy to TST
pull-requests:
'**':
- parallel:
steps:
- step:
name: Maven
caches:
- maven
script:
- export TESTCONTAINERS_RYUK_DISABLED=true
- export MAVEN_OPTS="-Xmx1024m"
- mvn -B -U clean verify sonar:sonar -s .m2/settings.xml -Dbuild=bitbucket -Dsonar.host.url=${SONAR_HOST} -Dsonar.projectKey=${SONAR_PROJECT} -Dsonar.login=${SONAR_USERNAME} -Dsonar.password=${SONAR_PASSWORD} -Dsonar.branch.name="$BITBUCKET_BRANCH"
artifacts:
- "**/*.jar"
- step:
<<: *sigridCI
custom:
update-dependencies:
- step:
name: Dependencies
caches:
- maven
script:
- apt-get update
- apt-get install git -y
- git --version
- export TESTCONTAINERS_RYUK_DISABLED=true
- export MAVEN_OPTS="-Xmx1024m"
# Disabled update-parent till they implement includes parameter like the other update plugins.
# - mvn versions:update-parent "-DparentVersion=(,2.0)" -B -s .m2/settings.xml
- mvn versions:update-properties -DallowMajorUpdates=false -Dincludes=be.vlaanderen*:* -B -s .m2/settings.xml
- mvn versions:use-releases -Dincludes=be.vlaanderen*:* -B -s .m2/settings.xml
- mvn versions:use-latest-versions -DallowMajorUpdates=false -Dincludes=be.vlaanderen*:* -B -s .m2/settings.xml
- mvn versions:commit
- mvn -B -U clean deploy -s .m2/settings.xml -Dbuild=bitbucket -Pdocker
- git diff-index --quiet HEAD || git commit -a -m'Bitbucket automated update of released dependencies'
- git push
after-script:
- chmod +x scheduler-slack-publisher.sh
- ./scheduler-slack-publisher.sh 'update-dependencies'
create-hotfix:
- variables:
- name: starting_branch_of_hotfix
- step:
name: Creating hotfix branch
caches:
- maven
script:
- export TESTCONTAINERS_RYUK_DISABLED=true
- chmod +x create-hotfix.sh
- ./create-hotfix.sh
finish-hotfix:
- variables:
- name: skipMergeDev
- step:
name: Finishing hotfix
caches:
- maven
script:
- export TESTCONTAINERS_RYUK_DISABLED=true
- chmod +x finish-hotfix.sh
- ./finish-hotfix.sh
create-support:
- variables:
- name: starting_tag
- step:
name: Creating support branch
caches:
- maven
script:
- export TESTCONTAINERS_RYUK_DISABLED=true
- chmod +x create-support.sh
- ./create-support.sh
maven-release:
- step: *release
- step: *githubMirror
deploy-released-version:
- step:
name: Check
caches:
- maven
script:
# Only run for released version
- mvn -B -s .m2/settings.xml org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce -Drules=requireReleaseVersion
- mkdir -p target
- mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout > target/pom_version
artifacts:
- target/pom_version
- step:
<<: *deploy
name: Deploy release to TST
deployment: TST_SOLID
- step:
<<: *newmanTest
name: Verify release to TST
- step:
<<: *deploy
name: Deploy release to TNI
deployment: TNI_SOLID
- step:
<<: *newmanTest
name: Verify release to TNI
- step:
<<: *deploy
name: Deploy release to PRD
trigger: manual
deployment: PRD_SOLID
owasp-dependencies-check:
- step:
name: Owasp Dependencies Check
caches:
- maven
script:
- export MAVEN_OPTS="-Xmx1024m"
- mvn -B org.owasp:dependency-check-maven:7.4.4:aggregate -DskipSystemScope=true "-DsuppressionFile=.owasp/owasp-suppression.xml" "-DhintsFile=.owasp/owasp-hints.xml" -DfailBuildOnCVSS=7 -DnvdApiKey=$NVD_API_KEY -s .m2/settings.xml
artifacts:
- target/dependency-check-report.html
after-script:
- chmod +x scheduler-slack-publisher.sh
- ./scheduler-slack-publisher.sh 'owasp-dependency-check'
- curl -X PUT -u $ARTIFACTORY_USER:$ARTIFACTORY_PASSWORD -T target/dependency-check-report.html "https://vlaamseoverheid.jfrog.io/vlaamseoverheid/magda-owasp/${BITBUCKET_REPO_SLUG}/${BITBUCKET_REPO_SLUG}-${BITBUCKET_BUILD_NUMBER}-$(date +%Y%m%d).html"
stable-develop-check:
- step:
<<: *build
after-script:
- chmod +x scheduler-slack-publisher.sh
- ./scheduler-slack-publisher.sh 'stable-develop-check'
rebuild-docker-from-tag:
- variables:
- name: rebuild_git_tag
- step: *dockerRebuildFromTag
options:
docker: true
size: 2x