-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipeline
More file actions
47 lines (42 loc) · 1.42 KB
/
pipeline
File metadata and controls
47 lines (42 loc) · 1.42 KB
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
pipeline {
agent any
environment {
GIT_URL = "https://github.com/Development-study/-CI-CD-Study.git"
SERVICE_NAME = ""
IMG_NAME = ""
IMG_VERSION = ""
CONTAINER_NAME = ""
DOCKER_ID = ""
DOCKER_PW = ""
}
stages {
stage('Pull') {
steps {
git url: "${GIT_URL}", branch: "master/${SERVICE_NAME}", poll: true, changelog: true
}
}
stage('Build') {
steps {
echo 'SpringBoot Gradle Project Build'
sh "chmod +x ./${SERVICE_NAME}/gradlew"
sh "./${SERVICE_NAME}/gradlew clean build"
}
}
stage('Dockerize') {
steps {
echo 'Docker Image Build And Image Push'
sh "docker build -t ${DOCKER_ID}/${IMG_NAME}:${IMG_VERSION} ."
sh "docker login -u ${DOCKER_ID} -p ${DOCKER_PW}"
sh "docker push ${DOCKER_ID}/${IMG_NAME}:${IMG_VERSION}"
}
}
stage('Deploy') {
steps {
echo 'Docker Container Run'
sh "docker ps -q --filter 'name=${CONTAINER_NAME}' | xargs -r docker stop"
sh "docker ps -aq --filter 'name=${CONTAINER_NAME}' | xargs -r docker rm"
sh "docker run -d --name ${CONTAINER_NAME} -p 8080:8080 ${DOCKER_ID}/${IMG_NAME}:${IMG_VERSION}"
}
}
}
}