-
Notifications
You must be signed in to change notification settings - Fork 7
/
Jenkinsfile
71 lines (63 loc) · 2.05 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
67
68
69
70
71
#!groovy
node {
def deployable_branches = ["master"]
stage('Checkout') {
checkout scm
}
dockerStage('Build') {
echo "Branch is: ${env.BRANCH_NAME}"
echo "Build is: ${env.BUILD_NUMBER}"
sh('''
./develop.sh sanity
./develop.sh recurse build prod
./develop.sh recurse build prod-date
''')
}
if (deployable_branches.contains(env.BRANCH_NAME)) {
dockerStage('Publish') {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'dockerbot',
usernameVariable: 'DOCKER_USERNAME',
passwordVariable: 'DOCKER_PASSWORD']]) {
sh("""
docker login -u "${env.DOCKER_USERNAME}" --password="${env.DOCKER_PASSWORD}"
./develop.sh recurse push prod
./develop.sh recurse push prod-date
""")
}
}
}
}
/*
* dockerStage
*
* Custom stage that wraps the stage in timestamps and AnsiColorBuildWrapper
* Prior to exit wrfy is used to kill all running containers and cleanup.
*/
def dockerStage(String label,
List<String> artifacts=[],
List<String> testResults=[],
Closure body) {
stage(label) {
try {
timestamps {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
body.call()
}
}
} catch (Exception e) {
currentBuild.result = 'FAILURE'
throw e
} finally {
for (artifact in artifacts) {
step([$class: 'ArtifactArchiver', artifacts: artifact, fingerprint: false, excludes: null])
}
for (testResult in testResults) {
step([$class: 'JUnitResultArchiver', testResults: testResult])
}
sh('''
/env/bin/wrfy kill-all --force
/env/bin/wrfy scrub --force
''')
}
}
}