forked from kishorebhatia/pipeline-as-code-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
53 lines (44 loc) · 955 Bytes
/
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
#!groovy
stage 'Dev'
node ('docker-cloud') {
checkout scm
mvn '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 ('docker-cloud') {
deploy 'staging'
}
input message: "Does staging look good?"
try {
checkpoint('Before production')
} catch (NoSuchMethodError _) {
echo 'Checkpoint feature available in CloudBees Jenkins Enterprise.'
}
stage name: 'Production', concurrency: 1
node ('docker-cloud'){
echo 'Production server looks to be alive'
deploy 'production'
echo "Deployed to production"
}
def mvn(args) {
sh "${tool 'Maven 3.x'}/bin/mvn ${args}"
}
def runTests(duration) {
node {
sh "sleep ${duration}"
}
}
def deploy(id) {
unstash 'war'
sh "cp x.war /tmp/${id}.war"
}
def undeploy(id) {
sh "rm /tmp/${id}.war"
}