forked from evernym/sovrin-client-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
110 lines (89 loc) · 2.3 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!groovy
@Library('SovrinHelpers') _
name = 'sovrin-client-rust'
def err
def publishBranch = (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'devel')
try {
// ALL BRANCHES: master, devel, PRs
// 1. TEST
stage('Test') {
parallel 'ubuntu-test':{
node('ubuntu') {
stage('Ubuntu Test') {
testUbuntu()
}
}
}
}
if (!publishBranch) {
echo "${env.BRANCH_NAME}: skip publishing"
return
}
// 2. PUBLISH TO Cargo
stage('Publish to Cargo') {
node('ubuntu') {
publishToCargo()
}
}
} catch(e) {
currentBuild.result = "FAILED"
node('ubuntu-master') {
sendNotification.fail([slack: publishBranch])
}
err = e
} finally {
if (err) {
throw err
}
currentBuild.result = "SUCCESS"
if (publishBranch) {
node('ubuntu-master') {
sendNotification.success(name)
}
}
}
def testUbuntu() {
try {
echo 'Ubuntu Test: Checkout csm'
checkout scm
echo 'Ubuntu Test: Build docker image'
def testEnv = dockerHelpers.build(name)
testEnv.inside {
echo 'Ubuntu Test: Test'
sh 'cargo update'
try {
sh 'cargo test-xunit'
}
finally {
junit 'test-results.xml'
}
}
}
finally {
echo 'Ubuntu Test: Cleanup'
step([$class: 'WsCleanup'])
}
}
def publishToCargo() {
try {
echo 'Publish to Cargo: Checkout csm'
checkout scm
echo 'Publish to Cargo: Build docker image'
def testEnv = dockerHelpers.build(name)
testEnv.inside {
echo 'Update version'
def suffix = env.BRANCH_NAME == 'master' ? env.BUILD_NUMBER : 'devel-' + env.BUILD_NUMBER;
sh 'chmod -R 777 ci'
sh "ci/update-package-version.sh $suffix"
withCredentials([string(credentialsId: 'cargoSecretKey', variable: 'SECRET')]) {
sh 'cargo login $SECRET'
}
sh 'cargo package --allow-dirty'
sh 'cargo publish --allow-dirty'
}
}
finally {
echo 'Publish to cargo: Cleanup'
step([$class: 'WsCleanup'])
}
}