-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
84 lines (83 loc) · 2.49 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
pipeline{
agent any
environment {
SCRIPT_PATH = '/var/jenkins_home/custom/snapcampus'
}
tools {
gradle 'gradle 8.6'
}
stages{
stage('Checkout') {
steps {
checkout scm
}
}
stage('Get Commit Message') {
steps {
script {
def gitCommitMessage = sh(
script: "git log -1 --pretty=%B",
returnStdout: true
).trim()
echo "Commit Message: ${gitCommitMessage}"
env.GIT_COMMIT_MESSAGE = gitCommitMessage
}
}
}
stage('Prepare'){
steps {
sh 'gradle clean'
}
}
stage('Replace Prod Properties') {
steps {
withCredentials([file(credentialsId: 'snapCampusProd', variable: 'snapCampusProd')]) {
script {
sh 'cp $snapCampusProd ./src/main/resources/application-prod.yml'
}
}
}
}
stage('Build') {
steps {
sh 'gradle build -x test'
}
}
stage('Test') {
steps {
sh 'gradle test'
}
}
stage('Deploy') {
steps {
sh '''
cp ./docker/docker-compose.blue.yml ${SCRIPT_PATH}
cp ./docker/docker-compose.green.yml ${SCRIPT_PATH}
cp ./docker/Dockerfile ${SCRIPT_PATH}
cp ./scripts/deploy.sh ${SCRIPT_PATH}
cp ./build/libs/*.jar ${SCRIPT_PATH}
chmod +x ${SCRIPT_PATH}/deploy.sh
${SCRIPT_PATH}/deploy.sh
'''
}
}
}
post {
success {
slackSend (
color: '#00FF00',
message: "성공: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL}). 최근 커밋: '${env.GIT_COMMIT_MESSAGE}'",
iconEmoji: ":tada:",
username: "봇이야"
)
}
failure {
slackSend (
color: '#FF0000',
message: "실패: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL}). 최근 커밋: '${env.GIT_COMMIT_MESSAGE}'",
iconEmoji: ":tada:",
username: "봇이야"
)
}
}
}