/
azure-pipelines.yml
110 lines (95 loc) · 3.57 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
# For reference, see https://aka.ms/yaml
variables:
M2_LOCAL_REPO: $(Pipeline.Workspace)/local-maven-repo
MAVEN_OPTS: '-Dmaven.repo.local=$(M2_LOCAL_REPO)'
# mitigation for https://issues.sonatype.org/browse/NEXUS-27902
JDK_JAVA_OPTIONS: '--add-opens java.base/java.util=ALL-UNNAMED'
trigger:
batch: true
schedules:
- cron: "0 0 * * *"
displayName: Daily scheduled run
branches:
include:
- develop
#exclude:
always: true
jobs:
- job: testframework
pool: 'ubuntu-20.4-DS1_v2-adopt-adoptium-jdk'
continueOnError: false
timeoutInMinutes: 20
variables:
SKIP_PUBLICATION: false
VERSION_OVERRIDE:
workspace:
clean: all
steps:
- task: Cache@2
inputs:
key: 'mvn | "$(Agent.OS)" | pom.xml'
restoreKeys: |
mvn | "$(Agent.OS)"
mvn
path: $(M2_LOCAL_REPO)
displayName: Configure maven caching
- task: DownloadSecureFile@1
name: pgpPrivateKey
displayName: 'Secrets - download pgp key'
inputs:
secureFile: 'order-iom-project-archetype-gpg_private_key_iom.pgp'
- task: MavenAuthenticate@0
inputs:
artifactsFeeds: order-iom-snapshots
mavenServiceConnections: order-iom-sonatype-ossrh
timeoutInMinutes: 1
displayName: "Maven authenticate"
- task: JavaToolInstaller@0
inputs:
versionSpec: '17'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- script: |
# Only some certain branches are allowed for publication!
# Note: due to weird implementation, Azure pipelines will cut off everything before the last trailing slash
# "feature/some-feature" will become "some-feature"
if ! echo "$BUILD_SOURCEBRANCHNAME" | grep -q '^develop$\|^release-\|^main$'; then
# from now on we have to use GitHubs branch name convention: "[issue-number]-issue-description"
# e.g. 39-allow-usage-of-feature-branch-snapshots-in-iom-platform-tests
IFS="-" read -ra VERSION_SPLIT <<< "$BUILD_SOURCEBRANCHNAME"
POM_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout | tail -1)
FEATURE_BRANCH_NUMBER=${VERSION_SPLIT[0]}
if (! echo $FEATURE_BRANCH_NUMBER | grep -E -q '^[0-9]+$') || (! echo $POM_VERSION | grep -q -e '-SNAPSHOT$') ; then
echo "##vso[task.setvariable variable=SKIP_PUBLICATION;]true"
echo "##vso[task.logissue type=warning] publication skipped - encountered unparseable branch name"
else
VERSION_OVERRIDE=$(echo $POM_VERSION | sed -E 's/^(.+)(-SNAPSHOT)$/\1-'"$FEATURE_BRANCH_NUMBER"'\2/')
echo "##vso[task.setvariable variable=VERSION_OVERRIDE;]$VERSION_OVERRIDE"
fi
fi
timeoutInMinutes: 2
displayName: "Check for publication / release build"
#enabled: false
- script: |
./mvnw versions:set -DnewVersion=$VERSION_OVERRIDE
timeoutInMinutes: 10
displayName: "Set branch specific version"
condition: ne(variables.VERSION_OVERRIDE, '')
- script: |
./mvnw clean verify
timeoutInMinutes: 10
displayName: "Build test-framework"
condition: and(succeeded(), eq(variables.SKIP_PUBLICATION, true))
env:
PGP_PASSPHRASE: "literal:$(pgpPassphrase)"
PGP_SECRETKEY: "keyfile:$(pgpPrivateKey.secureFilePath)"
- script: |
./mvnw clean deploy
timeoutInMinutes: 10
displayName: "Publish test-framework"
#enabled: false
condition: and(succeeded(), eq(variables.SKIP_PUBLICATION, false))
env:
PGP_PASSPHRASE: "literal:$(pgpPassphrase)"
PGP_SECRETKEY: "keyfile:$(pgpPrivateKey.secureFilePath)"
- task: PublishTestResults@2