-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
146 lines (128 loc) · 5.42 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
pipeline {
agent any
stages {
stage("CI/CD start") {
steps {
script {
def Author_ID = sh(script: "git show -s --pretty=%an", returnStdout: true).trim()
def Author_Name = sh(script: "git show -s --pretty=%ae", returnStdout: true).trim()
mattermostSend (
color: '#D0E0E3',
icon: "https://jenkins.io/images/logos/jenkins/jenkins.png",
message: "배포 출발 합니다 🛫 \n${env.JOB_NAME} #${env.BUILD_NUMBER} by ${Author_ID}(${Author_Name}) <- 얘가 시작함 \n(<${env.BUILD_URL}|Details>)"
)
}
}
}
stage("checkout_fe_consumer") {
steps {
script {
git credentialsId: 'gitlab', url: 'https://lab.ssafy.com/s10-final/S10P31D104.git', branch: "feConsumer"
}
}
}
stage("fe_consumer_env download") {
steps {
withCredentials([file(credentialsId: 'fe_consumer_env', variable: 'configFile')]) {
script {
sh 'cp -rf $configFile ./frontend-consumer/.env'
}
}
}
}
stage('fe_consumer_build'){
steps{
script {
def feConsumerRunning = sh(script: 'docker ps -a --filter "name=fe-consumer" --format "{{.Names}}"', returnStdout: true).trim()
sh 'echo ${feConsumerRunning}'
if (feConsumerRunning) {
// fe container is running, stop and remove it
sh 'docker stop fe-consumer'
sh 'docker rm fe-consumer'
sh 'docker rmi fe-consumer'
}
}
sh 'docker build -t fe-consumer ./frontend-consumer'
sh 'docker run -d --name fe-consumer -p 5173:5173 fe-consumer'
}
}
stage("checkout_fe_seller") {
steps {
script {
git credentialsId: 'gitlab', url: 'https://lab.ssafy.com/s10-final/S10P31D104.git', branch: "feSeller"
}
}
}
stage("fe_seller_env download") {
steps {
withCredentials([file(credentialsId: 'fe_seller_env', variable: 'configFile')]) {
script {
sh 'cp -rf $configFile ./frontend-seller/.env'
}
}
}
}
stage('fe_seller_build'){
steps{
script {
def feSellerRunning = sh(script: 'docker ps -a --filter "name=fe-seller" --format "{{.Names}}"', returnStdout: true).trim()
sh 'echo ${feSellerRunning}'
if (feSellerRunning) {
// fe container is running, stop and remove it
sh 'docker stop fe-seller'
sh 'docker rm fe-seller'
sh 'docker rmi fe-seller'
}
}
sh 'docker build -t fe-seller ./frontend-seller'
sh 'docker run -d --name fe-seller -p 5174:5174 fe-seller'
}
}
stage("checkout_be") {
steps {
script {
git credentialsId: 'gitlab', url: 'https://lab.ssafy.com/s10-final/S10P31D104.git', branch: "be"
}
}
}
stage("secret.yml, fcm-certification download") {
steps {
withCredentials([file(credentialsId: 'application-secret', variable: 'configFile')]) {
script {
sh 'cp -rf $configFile ./backend/src/main/resources/application-secret.yml'
}
}
withCredentials([file(credentialsId: 'fcm-certification', variable: 'configFile')]) {
script {
sh 'cp -rf $configFile ./backend/src/main/resources/fcm-certification.json'
}
}
}
}
stage('be_build'){
steps{
script {
def beRunning = sh(script: 'docker ps -a --filter "name=be" --format "{{.Names}}"', returnStdout: true).trim()
sh 'echo ${beRunning}'
if (beRunning) {
// be container is running, stop and remove it
sh 'docker stop be'
sh 'docker rm be'
sh 'docker rmi be'
}
sh 'docker build -t be ./backend'
def dockerCmd = "docker run -d --name be -p 8081:8081 be"
sh dockerCmd
}
}
}
}
post {
success {
mattermostSend color: 'good', message: "Deploy Success! (${env.JOB_NAME}) #(${env.BUILD_NUMBER}) (<${env.BUILD_URL}|Open>) \n See the (<${env.BUILD_URL}console|console>)"
}
failure {
mattermostSend color: 'danger', message: "Deploy Fail! ${Author_ID}(${Author_Name}) <- 얘가 범인임 (${env.JOB_NAME}) #(${env.BUILD_NUMBER}) (<${env.BUILD_URL}|Open>) \n See the (<${env.BUILD_URL}console|console>)"
}
}
}