-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
104 lines (74 loc) · 1.96 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
pipeline {
environment {
registry = "thekingofklorine/jenkinscalculator"
registryCredential = 'dockerhub'
dockerImage=''
}
agent any
tools {
maven 'apache maven 3.6.3'
jdk 'JDK 11'
}
stages {
stage ('Clean') {
steps {
sh 'mvn clean'
}
}
stage ('Build') {
steps {
sh 'mvn compile'
}
}
stage ('Short Tests') {
steps {
sh 'mvn -Dtest=CalculatorTest test'
}
}
stage ('Long Tests') {
steps {
sh 'mvn -Dtest=CalculatorTestThorough test'
}
post {
success {
junit 'target/surefire-reports/**/*.xml'
}
}
}
stage ('Package') {
steps {
sh 'mvn package'
archiveArtifacts artifacts: 'src/**/*.java'
archiveArtifacts artifacts: 'target/*.jar'
}
}
stage ('Building image') {
steps {
script {
dockerImage = docker.build registry + ":$BUILD_NUMBER"
}
}
}
stage ('Deploy Image') {
steps {
script {
docker.withRegistry('', registryCredential) {
dockerImage.push()
}
}
}
}
stage ('Remove unused docker image') {
steps {
sh "docker rmi $registry:$BUILD_NUMBER"
}
}
}
post {
failure{
mail to: 'evan.sportsman@gmail.com',
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "Something is wrong with ${env.BUILD_URL}"
}
}
}