-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsFile
66 lines (59 loc) · 2.47 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
pipeline {
agent any
stages {
stage('Git Clone') {
steps {
echo 'Git Clone start'
git branch: 'main', url: 'https://github.com/Ludo-SMP/ludo-backend.git'
// des: private repo 접근을 위한 인증을 젠킨스 선언형 스크립트로 진행
// notice: Jenkins Credential Plugin 을 설치 및 설정해야 함
withCredentials([GitUsernamePassword(credentialsId: 'submodule_configuration', gitToolName: 'Default')]) {
// des: ludo-backend configuration submodule 을 최신화
echo 'submodule fetching start'
sh 'git submodule init'
sh 'git submodule update'
echo 'submodule fetching end'
}
echo 'Git Clone success'
}
}
// deprecated
// stage('Test') {
// steps {
// dir('./') {
// echo 'Test start'
// sh './gradlew clean test'
// echo 'Test success'
// }
// }
// }
stage('Build') {
steps {
dir('./') {
echo 'Build start'
sh './gradlew bootJar'
echo 'Build success'
}
}
}
stage('Deploy') {
steps {
dir('./build/libs/') {
sshagent(credentials:['ludo-backend-ssh']) {
echo 'Deploy start'
// Deploy - Monitoring
// 그라파나, 프로메테우스 재실행 쉘 스크립트 필요 + 환경변수
// 1. docker hub push, 모니터링 인스턴스 docker hub pull
// 2(V). docker-compose.yaml 파일을 그냥 배포, 인스턴스에서 쉘 스크립트 실행
// des: jar 파일 배포
sh 'scp study-matching-platform-0.0.1-SNAPSHOT.jar [email protected]:/home/build'
echo 'Deploy end'
// des: 해당 경로의 자동화 스크립트 run.sh를 실행하여 애플리케이션을 구동
// notice: 해당 경로에 run.sh 파일이 존재해야 함
sh 'ssh -t [email protected] /home/build/run.sh'
}
}
}
}
}
}