-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
75 lines (68 loc) · 2.72 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
pipeline {
agent any
stages {
stage('Checkout') {
steps {
// GitHub 프로젝트 클론 및 백엔드 브랜치로 전환
checkout([$class: 'GitSCM', branches: [[name: 'main']],
doGenerateSubmoduleConfigurations: false,
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'Patabear', url: '[email protected]:JuneHyung/Bumpy.git']]])
}
}
stage('npm build')
{
steps {
dir('develop/frontend/bumpy-nuxt3') {
sh 'npm install'
sh 'npm run generate'
}
}
}
stage('Build') {
steps {
// Gradle을 사용하여 프로젝트 빌드
dir('develop/backend') {
sh 'chmod +x gradlew'
sh './gradlew build'
}
}
}
stage('Copy Files to Remote Server - Frontend') {
steps {
// 빌드된 파일을 원격 서버로 복사
dir('develop/frontend/bumpy-nuxt3/.output/public') {
sshagent(credentials: ['server1ssh']) {
sh 'ssh [email protected] "rm -rf /home/server1/nginx/dist/* && cp -r /home/server1/jenkins/jenkins_home/workspace/bumpy-front/develop/frontend/bumpy-nuxt3/.output/public/* /home/server1/nginx/dist/"'
}
}
}
}
stage('Copy Files to Remote Server - backend') {
steps {
// 빌드된 파일을 원격 서버로 복사
dir('develop/backend/build/libs') {
sshagent(credentials: ['server1ssh']) {
sh 'ssh [email protected] "cp /home/server1/jenkins/jenkins_home/workspace/bumpy-back/develop/backend/build/libs/* /home/server1/bumpy/jar/"'
}
}
}
}
stage('Deploy with Docker Compose - Frontend') {
steps {
// 원격 서버에서 Docker Compose 실행
sshagent(credentials: ['server1ssh']) {
sh 'ssh [email protected] "cd /home/server1/nginx && docker-compose down && docker-compose up -d --build"'
}
}
}
stage('Deploy with Docker Compose - backend') {
steps {
// 원격 서버에서 Docker Compose 실행
sshagent(credentials: ['server1ssh']) {
sh 'ssh [email protected] "cd /home/server1/bumpy && docker-compose down && docker-compose up -d --build"'
}
}
}
}
}