-
Notifications
You must be signed in to change notification settings - Fork 229
/
Jenkinsfile
80 lines (67 loc) · 2.49 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
#!groovy
@Library('github.com/triologygmbh/jenkinsfile@ad12c8a9') _
catchError {
node('docker') { // Require a build executor with docker (label)
properties([
pipelineTriggers(createPipelineTriggers()),
disableConcurrentBuilds(),
buildDiscarder(logRotator(numToKeepStr: '10'))
])
stage('Checkout') {
checkout scm
}
stage('Build') {
mvn 'clean install -DskipTests'
archiveArtifacts '**/target/*.*ar'
}
parallel(
unitTest: {
stage('Unit Test') {
catchError {
mvn 'test'
}
junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml'
}
},
integrationTest: {
stage('Integration Test') {
if (isTimeTriggeredBuild()) {
catchError {
mvn 'verify -DskipUnitTests -Parq-wildfly-swarm '
}
junit allowEmptyResults: true, testResults: '**/target/failsafe-reports/*.xml'
}
}
}
)
stage('Statical Code Analysis') {
withSonarQubeEnv('sonarcloud.io-cloudogu') {
mvn "$SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN " +
// Additionally needed for sonarcloud.io (EXTRA_PROPS would be the place to configure sonar.organization)
"$SONAR_EXTRA_PROPS " +
// Addionally needed when using the branch plugin (e.g. on sonarcloud.io)
"-Dsonar.branch.name=$BRANCH_NAME -Dsonar.branch.target=master"
}
}
}
stage('Quality Gate') {
if (currentBuild.currentResult == 'SUCCESS') {
timeout(time: 2, unit: 'MINUTES') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
unstable("Pipeline unstable due to quality gate failure: ${qg.status}")
}
}
}
}
}
node {
mailIfStatusChanged env.EMAIL_RECIPIENTS
}
def createPipelineTriggers() {
if (env.BRANCH_NAME == 'master') {
// Run a nightly only for master
return [cron('H H(0-3) * * 1-5')]
}
return []
}