-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
89 lines (79 loc) · 2.91 KB
/
Jenkinsfile
File metadata and controls
89 lines (79 loc) · 2.91 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
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
pipeline {
agent any
environment {
DOCKER_HUB_ID = 'shyunnnn'
BE_IMAGE = "${DOCKER_HUB_ID}/compay-backend:latest"
FE_IMAGE = "${DOCKER_HUB_ID}/compay-frontend:latest"
POS_IMAGE = "${DOCKER_HUB_ID}/compay-pos:latest"
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Docker Build & Push') {
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', 'jenkins-token') {
echo "Backend Build & Push..."
dir('backend') {
sh "docker build --platform linux/amd64 -t ${BE_IMAGE} ."
sh "docker push ${BE_IMAGE}"
}
echo "Frontend Build & Push..."
dir('frontend/admin-web') {
withCredentials([file(credentialsId: 'COMPAY_ENV_FILE', variable: 'ENV_FILE')]) {
sh "cp ${ENV_FILE} ./.env"
}
sh "docker build --platform linux/amd64 -t ${FE_IMAGE} ."
sh "docker push ${FE_IMAGE}"
}
echo "POS Web Build & Push..."
dir('frontend/pos-web') {
sh "docker build --platform linux/amd64 -t ${POS_IMAGE} ."
sh "docker push ${POS_IMAGE}"
}
}
}
}
}
stage('Deploy') {
steps {
script {
echo "Latest Image Pull..."
sh 'docker compose pull'
withCredentials([file(credentialsId: 'COMPAY_ENV_FILE', variable: 'ENV_FILE')]) {
sh "cp ${ENV_FILE} ./.env"
}
echo "Container Replace..."
sh 'docker compose up -d --quiet-pull'
}
}
}
stage('Cleanup') {
steps {
echo "Image & Workspace Cleanup..."
// 빌드 후 남은 찌꺼기 이미지 정리
sh 'docker image prune -f'
cleanWs()
}
}
}
post {
success {
mattermostSend(
color: 'good',
icon: 'https://jenkins.io/images/logos/jenkins/jenkins.png',
message: "✅ **Build SUCCESS!** #${env.BUILD_NUMBER}"
)
}
failure {
mattermostSend(
color: 'danger',
icon: 'https://jenkins.io/images/logos/jenkins/jenkins.png',
message: "🚨 **Build FAILED...** #${env.BUILD_NUMBER}"
)
}
}
}