-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathflow.groovy
56 lines (49 loc) · 1.38 KB
/
flow.groovy
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
def devQAStaging() {
env.PATH="${tool 'Maven 3.x'}/bin:${env.PATH}"
stage 'Dev'
sh 'mvn -o clean package'
archive 'target/x.war'
stage 'QA'
parallel(longerTests: {
runWithServer {url ->
sh "mvn -o -f sometests/pom.xml test -Durl=${url} -Dduration=30"
}
}, quickerTests: {
runWithServer {url ->
sh "mvn -o -f sometests/pom.xml test -Durl=${url} -Dduration=20"
}
})
stage name: 'Staging', concurrency: 1
deploy 'target/x.war', 'staging'
}
def production() {
input message: "Does http://localhost:8080/staging/ look good?"
try {
checkpoint('Before production')
} catch (NoSuchMethodError _) {
echo 'Checkpoint feature available in Jenkins Enterprise by CloudBees.'
}
stage name: 'Production', concurrency: 1
node('master') {
sh 'curl -I http://localhost:8080/staging/'
unarchive mapping: ['target/x.war' : 'x.war']
deploy 'x.war', 'production'
echo 'Deployed to http://localhost:8080/production/'
}
}
def deploy(war, id) {
sh "cp ${war} /tmp/webapps/${id}.war"
}
def undeploy(id) {
sh "rm /tmp/webapps/${id}.war"
}
def runWithServer(body) {
def id = UUID.randomUUID().toString()
deploy 'target/x.war', id
try {
body.call "http://localhost:8080/${id}/"
} finally {
undeploy id
}
}
return this;