-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
70 lines (69 loc) · 2.6 KB
/
Copy pathJenkinsfile
File metadata and controls
70 lines (69 loc) · 2.6 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
pipeline {
agent any
tools {
maven 'Maven 3.3.9'
jdk 'Java8 JDK'
}
stages {
stage ('Initialize') {
steps {
sh '''
echo "PATH = ${PATH}"
echo "M2_HOME = ${M2_HOME}"
'''
sh "mvn --version"
}
}
stage ('Build') {
steps {
echo 'execute mvn clean install'
sh "mvn clean install"
}
}
stage ('Deploy Green') {
steps {
withCredentials([usernamePassword(credentialsId: 'pksivPivotalId', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'cf login -u $USERNAME -p $PASSWORD -a api.run.pivotal.io --skip-ssl-validation'
sh 'cf push simple-spring-examples-green -n simple-spring-examples-ps-green'
sh 'cf map-route simple-spring-examples-green cfapps.io -n simple-spring-examples-ps-green'
}
}
}
stage ('Route Traffic to Green ?') {
input {
message "Route traffic to Green instance?"
ok "Yes"
}
steps {
withCredentials([usernamePassword(credentialsId: 'pksivPivotalId', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'cf map-route simple-spring-examples-green cfapps.io -n simple-spring-examples-ps'
}
}
}
stage ('Unroute Traffic from Blue ?') {
input {
message "Stop routing traffic to Blue instance?"
ok "Yes"
}
steps {
withCredentials([usernamePassword(credentialsId: 'pksivPivotalId', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'cf unmap-route simple-spring-examples cfapps.io -n simple-spring-examples-ps'
sh 'cf unmap-route simple-spring-examples-green cfapps.io -n simple-spring-examples-ps-green'
}
}
}
stage ('Cleanup Instances?') {
input {
message "Delete blue instance, delete temporary green route, rename green application."
ok "Yes"
}
steps {
withCredentials([usernamePassword(credentialsId: 'pksivPivotalId', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'cf delete simple-spring-examples -f'
sh 'cf delete-route cfapps.io -n simple-spring-examples-ps-green -f'
sh 'cf rename simple-spring-examples-green simple-spring-examples'
}
}
}
}
}