forked from Kyle-TM99/OneStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
81 lines (72 loc) · 2.23 KB
/
Jenkinsfile
File metadata and controls
81 lines (72 loc) · 2.23 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
pipeline {
agent any
environment {
DOCKER_COMPOSE = '/usr/local/bin/docker-compose'
KAKAO_CLIENT_ID = credentials('kakao-client-id')
KAKAO_REDIRECT_URI = credentials('kakao-redirect-uri')
GOOGLE_CLIENT_ID = credentials('google-client-id')
GOOGLE_CLIENT_SECRET = credentials('google-client-secret')
GOOGLE_REDIRECT_URI = credentials('google-redirect-uri')
GMAIL_USERNAME = credentials('gmail-username')
GMAIL_PASSWORD = credentials('gmail-password')
PORTONE_API_KEY = credentials('portone-api-key')
PORTONE_API_SECRET = credentials('portone-api-secret')
}
stages {
stage('Clean Workspace') {
steps {
cleanWs()
}
}
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build') {
steps {
sh '''
# gradlew 파일에 실행 권한 부여
chmod +x ./gradlew
./gradlew clean build -x test
'''
}
}
stage('Prepare Environment') {
steps {
sh '''
sudo mkdir -p /usr/share/nginx/html/images
sudo chown -R $(id -u):$(id -g) /usr/share/nginx/html/images
sudo chmod -R 755 /usr/share/nginx/html/images
'''
}
}
stage('Deploy') {
steps {
sh '''
# 이전 컨테이너 중지
${DOCKER_COMPOSE} down --volumes=false || true
# 컨테이너 시작
${DOCKER_COMPOSE} up -d --build
'''
}
}
stage('Health Check') {
steps {
sh '${DOCKER_COMPOSE} ps'
}
}
}
post {
failure {
sh '''
if command -v ${DOCKER_COMPOSE} &> /dev/null; then
${DOCKER_COMPOSE} logs
fi
'''
}
always {
sh 'docker system prune -f --volumes=false'
}
}
}