-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
45 lines (45 loc) · 1.17 KB
/
Jenkinsfile
File metadata and controls
45 lines (45 loc) · 1.17 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
pipeline {
agent any
tools {
maven 'Maven' // Assume you configure Maven in Jenkins global tools
}
stages {
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t grid-app:latest .'
}
}
stage('Deploy Staging') {
steps {
sh 'docker-compose -f docker-compose.staging.yml up -d --build'
}
}
stage('Manual Approval') {
steps {
input message: 'Approve deployment to Production?', ok: 'Deploy'
}
}
stage('Deploy Prod') {
steps {
sh 'docker-compose -f docker-compose.prod.yml up -d --build'
}
}
}
post {
failure {
echo 'Pipeline failed - Rolling back'
sh 'docker-compose -f docker-compose.staging.yml down || true'
sh 'docker-compose -f docker-compose.prod.yml down || true'
}
}
}