forked from jleetutorial/maven-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile-docker
50 lines (46 loc) · 1.31 KB
/
Jenkinsfile-docker
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
pipeline {
agent any
tools {
maven 'mymaven'
jdk 'myjdk'
}
stages {
stage('Build') {
steps {
echo 'Packaging repo'
sh 'mvn clean package'
}
post {
success {
echo 'Now Archiving...'
archiveArtifacts artifacts: '**/target/*.war'
sh 'docker build . -t tomcatwebapp:latest'
sh 'docker run -d --name webapp-stage -p 8090:8080 --rm tomcatwebapp:latest'
}
}
}
stage('Deploy to staging') {
steps {
echo 'Deploying package to stage'
build job: 'deploy-to-staging'
}
}
stage ('Deploy to Production'){
steps{
timeout(time:5, unit:'DAYS'){
input message:'Approve PRODUCTION Deployment?'
}
sh 'docker run -d --name webapp-prod -p 8091:8080 --rm tomcatwebapp:latest'
build job: 'Deploy-to-Prod'
}
post {
success {
echo 'Code deployed to Production.'
}
failure {
echo ' Deployment failed.'
}
}
}
}
}