-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
66 lines (62 loc) · 2.2 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
64
65
66
#!/usr/bin/env groovy
def utils = new localhost.Utils()
node('Node1') {
println "Pipeline to run - ${utils.pipelineToRun}"
def branch = env.BRANCH_NAME
println "Branch - ${branch}"
def imagename = ""
stage("Checkout") {
scmCheckout {
deleteWorkspace = 'true'
}
}
try {
if (branch == "master") {
// clean up Docker environment
stage("Clean up") {
sh 'docker images prune'
sh 'docker-compose -f dev-compose.yml down'
}
// create Testing environment with Compose
stage("Unit Tests") {
// Don't wipe environment after this stage
scmCheckout {
deleteWorkspace = 'false'
}
println "Starting Consul"
sh 'mkdir -p .coverage'
sh 'chmod 777 .coverage'
println "Starting Tests"
println "GOPATH is ${GOPATH}"
sh 'docker-compose -f dev-compose.yml up --exit-code-from tests --build tests'
sh 'cp .coverage/cover.out ./cover.out'
println "Clean up"
sh 'docker-compose -f dev-compose.yml down'
}
// check if it is runnable with Compose
stage("Functional Tests") {
// don't wipe environment after this stage
scmCheckout {
deleteWorkspace = 'false'
}
sh 'sleep 10'
println "Starting BDD tests"
sh 'docker-compose -f dev-compose.yml up --exit-code-from functional --build functional'
println "Clean up"
sh 'docker-compose -f dev-compose.yml down'
}
// build and deploy changes to higher env
stage("E1 Deployment"){
sh 'sleep 10'
println "Application deployed successfully to E1"
}
}
// TODO Add steps to build and deploy to specific env
}
finally {
println "Clean up"
sh 'docker-compose -f dev-compose.yml down'
println 'current build status'
println "${currentBuild.result}"
}
}