-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkinsfile
executable file
·52 lines (45 loc) · 1.39 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
node {
environment {
BUILD_NUMBER = '1.0.0'
}
stage('Clone PetClinic') {
//Clone spring-petclinic project from GitHub repository
git branch: 'main',
url: 'https://github.com/babu2020/spring-petclinic.git'
}
stage('Build & Install') {
//run mvn wrapper for build, install and package
sh './mvnw -B -DskipTests clean install'
}
stage('Run Tests') {
//run all the Junit test
sh './mvnw test'
junit 'target/surefire-reports/*.xml'
}
stage('Package App') {
//package application
sh './mvnw package'
}
stage('Create Image - mvnw'){
//Create pet-clinic application image
sh 'whoami'
sh './mvnw spring-boot:build-image -Dspring-boot.build-image.imageName=pet-clinician-spring-boot-image -Dmaven.repo.local=/var/lib/jenkins/.m2/repository/'
}
stage('Create Image - Dockerfile'){
//Create pet-clinic application image
sh 'docker build -t petclinic:$BUILD_NUMBER .'
}
stage('Publish To Artifactory'){
def server = Artifactory.newServer url: "${ARTIFACTORY_URL}", username: "${ARTIFACTORY_USER_NAME}", password: "${ARTIFACTORY_PASSWORD}"
def uploadSpec = """{
"files": [
{
"pattern": "target/*.jar",
"target" : "${ARTIFACTORY_TARGET_REPO}",
"props" : "Unit-Tested=Yes"
}
]
}"""
server.upload(uploadSpec)
}
}