-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
56 lines (55 loc) · 2.06 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
pipeline {
agent any
stages {
// 2. gradle을 docker agent로 실행해 소스를 build합니다.
stage('Git clonning and Build') {
steps {
echo 'Git Clonning...'
git url: 'https://lab.ssafy.com/s06-webmobile4-sub2/S06P12D208',
credentialsId: 'jenkins-credentials-id'
sh 'ls -al'
dir('RollingPictures-Backend/') {
sh './gradlew cleanQuerydslSourcesDir'
sh './gradlew bootJar'
}
}
post {
success {
echo 'Successfully Cloned Repository And Spring Boot App Build'
}
failure {
error 'This pipeline stops here...'
}
}
}
// 3. 도커 이미지를 빌드합니다. (Dockerfile 필요)
stage('Docker build') {
steps {
echo 'Docker building...'
dir('RollingPictures-Backend/') {
sh 'docker build -t rolling-pictures:latest .'
}
}
post {
failure {
error 'This pipeline stops here...'
}
}
}
// 4. 기존 컨테이너와 이미지를 지우고 새로운 컨테이너를 실행합니다.
stage('Docker run') {
steps {
echo 'Docker running...'
sh 'docker ps -f name=rolling-pictures -q | xargs --no-run-if-empty docker container stop'
sh 'docker container ls -a --filter name=rolling-pictures --filter status=exited -q | xargs -r docker container rm'
sh 'docker images --no-trunc -a -q --filter="dangling=true" | xargs --no-run-if-empty docker rmi'
sh 'docker run -d -p 8185:8185 --name rolling-pictures rolling-pictures:latest'
}
post {
failure {
error 'This pipeline stops here...'
}
}
}
}
}