forked from apemberton/mobile-deposit-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flow.groovy
57 lines (54 loc) · 2.51 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
57
def dockerBuildTag = 'latest'
def buildVersion = null
def mobileDepositUiImage = null
stage 'build'
node('docker-cloud') {
//docker.withServer('tcp://127.0.0.1:1234'){ //run the following steps on this Docker host
docker.image('kmadel/maven:3.3.3-jdk-8').inside('-v /data:/data') { //use this image as the build environment
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/cloudbees/mobile-deposit-ui.git']]])
sh 'mvn -Dmaven.repo.local=/data/mvn/repo clean package'
//get new version of application from pom
def matcher = readFile('pom.xml') =~ '<version>(.+)</version>'
if (matcher) {
buildVersion = matcher[0][1]
echo "Released version ${buildVersion}"
}
matcher = null
}
//}
//build image and deploy to staging
docker.withServer('tcp://52.26.31.52:3376', 'beedemo-swarm-cert') { //run following steps on our staging server
stage 'build docker image'
dir('target') {
mobileDepositUiImage = docker.build "mobile-deposit-ui:${buildVersion}"
}
try {
sh "docker stop mobile-deposit-ui-stage"
sh "docker rm mobile-deposit-ui-stage"
} catch (Exception _) {
echo "no container to stop"
}
stage 'deploy to staging'
mobileDepositUiImage.run("--name mobile-deposit-ui-stage -p 82:8080")
}
docker.image('kmadel/maven:3.3.3-jdk-8').inside('-v /data:/data') {
stage 'functional-test'
sh 'mvn -Dmaven.repo.local=/data/mvn/repo verify'
}
}
stage 'awaiting approval'
//put input step outside of node so it doesn't tie up a slave
input 'UI Staged at http://54.165.201.3:82/deposit - Proceed with Production Deployment?'
stage 'deploy to production'
node('docker-cloud') {
docker.withServer('tcp://52.26.31.52:3376', 'beedemo-swarm-cert'){
try{
sh "docker stop mobile-deposit-ui"
sh "docker rm mobile-deposit-ui"
} catch (Exception _) {
echo "no container to stop"
}
mobileDepositUiImage.run("--name mobile-deposit-ui -p 80:8080")
sh 'curl http://webhook:[email protected]/mobile-team/docker-traceability/submitContainerStatus --data-urlencode inspectData="$(docker inspect mobile-deposit-ui)"'
}
}