forked from Informatievlaanderen/metadata-geonetwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
111 lines (109 loc) · 3.93 KB
/
azure-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
variables:
- name: subscription
value: METADATA-dev
- name: clusterRg
value: pre-md-cluster-rg
- name: clusterName
value: pre-md-cluster-aks
- name: mavenCacheFolder
value: $(Pipeline.Workspace)/.m2/repository
- name: mavenCacheOpts
value: '-Dmaven.repo.local=$(mavenCacheFolder)'
stages:
- stage: prebuild
pool: dv-prd-ubuntu2204
jobs:
# check whether we can/should skip this pipeline, e.g., for comment-only fixes
- job: skipcheck
steps:
- bash: |
echo "Testing whether we need to skip the pipeline."
substring='skipci'
echo "> substring: $substring"
echo "> commit message: $COMMIT_MESSAGE"
if [[ "$COMMIT_MESSAGE" == *"$substring"* ]];
then
echo "> '$substring' was found in the commit message."
echo "##vso[task.setvariable variable=skip;isoutput=true]true"
else
echo "##vso[task.setvariable variable=skip;isoutput=true]false"
fi
name: skipcheck
env:
COMMIT_MESSAGE: $(Build.SourceVersionMessage)
- stage: build
pool: dv-prd-ubuntu2204
dependsOn: prebuild
condition: and(succeeded('prebuild'),eq(dependencies.prebuild.outputs['skipcheck.skipcheck.skip'], 'false'))
jobs:
- job: build
timeoutInMinutes: "60"
steps:
- checkout: self
displayName: Set up repository
submodules: recursive # needed for submodules
- task: Bash@3
displayName: Set git commit sha as env var
inputs:
targetType: 'inline'
script: |
GIT_COMMIT_SHA=$(git rev-parse HEAD)
echo "GIT_COMMIT_SHA: ${GIT_COMMIT_SHA}"
echo "##vso[task.setvariable variable=GIT_COMMIT_SHA]${GIT_COMMIT_SHA}"
- task: Bash@3
displayName: Retrieve project version
inputs:
targetType: 'inline'
workingDirectory: 'vlaanderen'
script: |
VL_GEONETWORK_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VL_GEONETWORK_VERSION: ${VL_GEONETWORK_VERSION}"
echo "##vso[task.setvariable variable=VL_GEONETWORK_VERSION]${VL_GEONETWORK_VERSION}"
- task: Cache@2
inputs:
# bump 'versionx' to make sure the cache is cleared
key: 'version2 | maven | "$(Agent.OS)" | **/pom.xml'
restoreKeys: |
maven | "$(Agent.OS)"
maven
path: $(mavenCacheFolder)
displayName: Cache Maven local repo
- task: Maven@3
displayName: Build project artifacts
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m $(mavenCacheOpts)'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'clean install'
options: ' -DskipTests -Pwar -Dmaven.artifact.threads=30 -Dwro4j-prebuild-cache '
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: 'web/target/geonetwork.war'
ArtifactName: 'geonetwork.war'
publishLocation: 'Container'
- task: Docker@2
displayName: Build web image and push to preprod container registry (premdacr)
inputs:
containerRegistry: 'premdacr'
repository: 'metadata/geonetwork'
command: 'buildAndPush'
Dockerfile: 'web/Dockerfile'
tags: |
latest
$(GIT_COMMIT_SHA)
$(VL_GEONETWORK_VERSION)
- task: Docker@2
displayName: Build web image and push to preprod container registry (prdmdacr)
inputs:
containerRegistry: 'prdmdacr'
repository: 'metadata/geonetwork'
command: 'buildAndPush'
Dockerfile: 'web/Dockerfile'
tags: |
latest
$(GIT_COMMIT_SHA)
$(VL_GEONETWORK_VERSION)