-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
75 lines (71 loc) · 1.58 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
pipeline {
agent any
environment {
CONTAINER_NAME = 'ezfarm-con'
IMAGE_NAME = 'ezfarm-img'
}
stages {
stage('git pull'){
steps {
echo 'Git Pull - Start'
sh """
git fetch
git pull origin master
"""
}
post {
success {
echo 'Git Pull - Success'
}
failure {
error 'Git Pull - Failure'
}
}
}
stage('build'){
steps {
echo 'Build Start'
sh """
chmod 755 ./gradlew
./gradlew clean build
"""
}
post {
success {
echo 'Build Success'
}
failure {
error 'Build Failure -> Stop'
mail to: '[email protected]',
subject: "Jenkins Failure Build",
body: "Build Failed."
}
}
}
stage('deploy'){
steps {
echo 'Deploy Start'
sh """
docker stop ${CONTAINER_NAME}
docker rm ${CONTAINER_NAME}
docker rmi ${IMAGE_NAME}
docker build -t ${IMAGE_NAME} .
docker run -d --name ${CONTAINER_NAME} -p 9090:9090 -v /home/jenkins:/var/jenkins_home ${IMAGE_NAME}
"""
}
post {
success {
mail to: '[email protected]',
subject: "Jenkins Success Deploy",
body: "Deploy Success"
}
failure {
error 'Deploy Failure -> Stop'
mail to: '[email protected]',
subject: "Jenkins Failure Deploy",
body: "Deploy Failed."
}
}
}
}
}