-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
42 lines (38 loc) · 1.38 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
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
skipDefaultCheckout true
}
agent { label 'maven-agent' }
stages {
stage('Run maven') {
steps {
git(url:'https://github.com/fgibelin/spring-petclinic', branch: 'main')
withMaven(
options: [junitPublisher(disabled: true, healthScaleFactor: 1.0)],
publisherStrategy: 'EXPLICIT') {
sh 'mvn clean verify'
}
}
}
stage('Build Docker image') {
steps {
script {
pom = readMavenPom file: "pom.xml";
filesByGlob = findFiles(glob: "target/*.${pom.packaging}");
artifactPath = filesByGlob[0].path;
artifactExists = fileExists artifactPath;
if (artifactExists) {
echo "Building Docker image for spring-petclinic with version ${pom.version}"
sh "docker build -t spring-petclinic:${pom.version} --build-arg petclinicArtifact=./target/${pom.artifactId}-${pom.version}.${pom.packaging} ."
}
}
}
}
}
post {
always {
junit 'target/surefire-reports/**/*.xml'
}
}
}