-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.groovy
52 lines (46 loc) · 1.45 KB
/
Jenkinsfile.groovy
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
pipeline {
agent any
environment {
JAVA_HOME = tool name: 'JDK 17', type: 'jdk'
PATH = "${JAVA_HOME}/bin:${env.PATH}"
}
stages {
stage('Checkout') {
steps {
checkout scm // 코드 체크아웃 (코드가 scm에 등록되어 있는지 확인하는 단계)
}
}
stage('Project Build') {
steps {
// Java 17 설치
tool name: 'JDK 17', type: 'jdk'
// 프로젝트 빌드
sh 'chmod +x gradlew'
sh './gradlew build'
}
}
stage('Docker Build & Run') {
steps {
// Docker Image Build
sh 'docker build -t flint-back-docker:CD .'
withCredentials([usernamePassword(credentialsId: 'back', passwordVariable: 'flint', usernameVariable: 'rlgus2738')]) {
sh 'docker login -u rlgus2738 -p tktktkfkd5!'
}
sh 'docker tag flint-back-docker:CD rlgus2738/flint-back-docker:CD'
sh 'docker push rlgus2738/flint-back-docker:CD'
}
}
stage('Deploy on Server') {
steps {
// 배포할 스크립트 파일 실행
sh 'sudo chmod +x deploy_script.sh'
sh './deploy_script.sh'
}
}
}
post {
always {
sh 'docker logout'
}
}
}