-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
63 lines (53 loc) · 1.14 KB
/
Jenkinsfile
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
#!groovy
jettyUrl = 'http://localhost:8081/'
stage 'Dev'
node {
checkout scm
mvn '-o clean package'
dir('target') {stash name: 'war', includes: 'x.war'}
}
stage 'QA'
parallel(longerTests: {
runTests(30)
}, quickerTests: {
runTests(20)
})
stage name: 'Staging', concurrency: 1
node {
deploy 'staging'
}
input message: "Does http://192.168.56.101:9081/staging/ look good?"
stage name: 'Production', concurrency: 1
node {
sh "wget -O - -S ${jettyUrl}staging/"
echo 'Production server looks to be alive'
deploy 'production'
echo "Deployed to ${jettyUrl}production/"
}
def mvn(args) {
sh "${tool 'Maven 3.x'}/bin/mvn ${args}"
}
def runTests(duration) {
node {
checkout scm
runWithServer {url ->
mvn "-o -f sometests test -Durl=${url} -Dduration=${duration}"
}
}
}
def deploy(id) {
unstash 'war'
sh "cp x.war /tmp/webapps/${id}.war"
}
def undeploy(id) {
sh "rm /tmp/webapps/${id}.war"
}
def runWithServer(body) {
def id = UUID.randomUUID().toString()
deploy id
try {
body.call "${jettyUrl}${id}/"
} finally {
undeploy id
}
}