-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
97 lines (87 loc) · 3.08 KB
/
Copy pathJenkinsfile
File metadata and controls
97 lines (87 loc) · 3.08 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
pipeline {
agent any
triggers {
cron('0 1 * * *') // 매일 새벽 1시에 실행
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build') {
steps {
sh 'docker-compose build'
}
}
stage('Start Services') {
steps {
sh 'docker-compose up -d'
}
}
stage('Wait for Services') {
steps {
// 서비스들이 완전히 시작될 때까지 대기
sh 'docker-compose run --rm wait-for-it db:3306 -t 30'
sh 'docker-compose run --rm wait-for-it eureka-server:8761 -t 30'
sh 'docker-compose run --rm wait-for-it user-service:8086 -t 30'
sh 'docker-compose run --rm wait-for-it newsfeed-service:8083 -t 30'
sh 'docker-compose run --rm wait-for-it social-service:8084 -t 30'
sh 'docker-compose run --rm wait-for-it api-gateway:8081 -t 30'
}
}
stage('Check Service Health') {
steps {
script {
def services = [
[name: 'Eureka Server', port: 8761],
[name: 'API Gateway', port: 8081],
[name: 'User Service', port: 8086],
[name: 'Newsfeed Service', port: 8083],
[name: 'Social Service', port: 8084],
[name: 'Stock Service', port: 8085]
]
services.each { service ->
try {
sh "curl -f http://localhost:${service.port}/actuator/health || exit 1"
echo "${service.name} is healthy"
} catch (Exception e) {
error "${service.name} is not healthy"
}
}
}
}
}
stage('Run Integration Tests') {
steps {
script {
try {
sh 'docker-compose run --rm integration-test'
echo "Integration tests passed successfully"
} catch (Exception e) {
error "Integration tests failed: ${e.message}"
}
}
}
}
stage('Run Batch Job') {
steps {
script {
try {
sh 'docker-compose exec -T stock-service java -jar app.jar --spring.batch.job.names=updateStockPricesJob'
echo "Batch job completed successfully"
} catch (Exception e) {
error "Batch job failed: ${e.message}"
}
}
}
}
}
post {
always {
echo "Stopping services and cleaning up resources..."
sh 'docker-compose down'
echo "Cleanup completed"
}
}
}