forked from ari4java/ari4java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
67 lines (57 loc) · 1.78 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
node {
def pom
def version
stage('Checkout') {
checkout scm
}
stage('Preparation') {
pom = readMavenPom file: 'pom.xml'
version = pom.version.replace("-SNAPSHOT", ".${currentBuild.number}")
}
stage('Compile') {
withDockerContainer('elara/mvn:3.5.4_201') {
sh "mvn -B -e versions:set -DnewVersion=${version} clean compile"
}
}
// stage('Unit Tests') {
// withDockerContainer('elara/mvn:3.5.4_201') {
// sh 'mvn -B -e org.jacoco:jacoco-maven-plugin:prepare-agent test'
// junit '**/target/surefire-reports/TEST-*.xml'
// jacoco()
// }
// }
stage('SonarQube Analysis') {
withDockerContainer('elara/mvn:3.5.4_201') {
withSonarQubeEnv("SonarQube") {
sh 'mvn -B -e org.jacoco:jacoco-maven-plugin:prepare-agent sonar:sonar'
}
}
}
stage("SonarQube Quality Gate") {
timeout(time: 5, unit: 'MINUTES') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
stage('Package') {
withDockerContainer('elara/mvn:3.5.4_201') {
sh 'mvn -B -e -DskipTests package'
}
}
stage('Release') {
parallel 'Deploy': {
withDockerContainer('elara/mvn:3.5.4_201') {
sh 'mvn -B -e -DskipTests deploy'
}
}, 'Tag': {
sshagent(['cis-ssh']) {
sh('git config --global user.email "[email protected]"')
sh('git config --global user.name "jenkins"')
sh("git tag ${version}")
sh('git push --tags')
}
}
}
}