This repository has been archived by the owner on Jan 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
221 lines (217 loc) · 8.03 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
properties([parameters([
booleanParam(defaultValue: true, description: 'Build `iroha`', name: 'iroha'),
choice(choices: 'Debug\nRelease', description: 'Iroha build type', name: 'build_type'),
booleanParam(defaultValue: true, description: 'Build `bindings`', name: 'bindings'),
booleanParam(defaultValue: true, description: '', name: 'x86_64_linux'),
booleanParam(defaultValue: false, description: '', name: 'armv7_linux'),
booleanParam(defaultValue: false, description: '', name: 'armv8_linux'),
booleanParam(defaultValue: true, description: '', name: 'x86_64_macos'),
booleanParam(defaultValue: false, description: '', name: 'x86_64_win'),
booleanParam(defaultValue: true, description: 'Build Java bindings', name: 'JavaBindings'),
choice(choices: 'Release\nDebug', description: 'Java bindings build type', name: 'JBBuildType'),
string(defaultValue: 'jp.co.soramitsu.iroha', description: 'Java bindings package name', name: 'JBPackageName'),
booleanParam(defaultValue: true, description: 'Build Python2 bindings', name: 'Python2Bindings'),
booleanParam(defaultValue: false, description: 'Build Python3 bindings', name: 'Python3Bindings'),
choice(choices: 'Release\nDebug', description: 'Python bindings build type', name: 'PBBuildType'),
string(defaultValue: '4', description: 'How much parallelism should we exploit. "4" is optimal for machines with modest amount of memory and at least 4 cores', name: 'PARALLELISM')])])
pipeline {
environment {
CCACHE_DIR = '/opt/.ccache'
CCACHE_RELEASE_DIR = '/opt/.ccache-release'
SORABOT_TOKEN = credentials('SORABOT_TOKEN')
SONAR_TOKEN = credentials('SONAR_TOKEN')
GIT_RAW_BASE_URL = "https://raw.githubusercontent.com/hyperledger/libiroha"
DOCKER_REGISTRY_BASENAME = "hyperledger/libiroha"
IROHA_NETWORK = "iroha-0${CHANGE_ID}-${GIT_COMMIT}-${BUILD_NUMBER}"
IROHA_POSTGRES_HOST = "pg-0${CHANGE_ID}-${GIT_COMMIT}-${BUILD_NUMBER}"
IROHA_POSTGRES_USER = "pguser${GIT_COMMIT}"
IROHA_POSTGRES_PASSWORD = "${GIT_COMMIT}"
IROHA_POSTGRES_PORT = 5432
CHANGE_BRANCH_LOCAL = ''
}
options {
buildDiscarder(logRotator(numToKeepStr: '20'))
timestamps()
}
agent any
stages {
stage ('Stop same job builds') {
agent { label 'master' }
steps {
script {
// need this for develop->master PR cases
// CHANGE_BRANCH is not defined if this is a branch build
try {
CHANGE_BRANCH_LOCAL = CHANGE_BRANCH
}
catch(MissingPropertyException e) { }
if (GIT_LOCAL_BRANCH != "develop" && CHANGE_BRANCH_LOCAL != "develop") {
def builds = load ".jenkinsci/cancel-builds-same-job.groovy"
builds.cancelSameJobBuilds()
}
}
}
}
stage('Build native library') {
when {
allOf {
expression { params.build_type == 'Debug' }
expression { return params.iroha }
}
}
parallel {
stage ('x86_64_linux') {
when {
beforeAgent true
expression { return params.x86_64_linux }
}
agent { label 'x86_64' }
steps {
script {
debugBuild = load ".jenkinsci/linux-debug-build.groovy"
debugBuild.doDebugBuild()
}
}
post {
cleanup {
script {
def cleanup = load ".jenkinsci/docker-cleanup.groovy"
cleanup.doDockerCleanup()
cleanWs()
}
}
}
}
stage('x86_64_macos') {
when {
beforeAgent true
expression { return params.x86_64_macos }
}
agent { label 'mac' }
steps {
script {
debugBuild = load ".jenkinsci/mac-debug-build.groovy"
debugBuild.doDebugBuild()
}
}
post {
always {
script {
cleanWs()
sh """
pg_ctl -D /var/jenkins/${GIT_COMMIT}-${BUILD_NUMBER}/ stop && \
rm -rf /var/jenkins/${GIT_COMMIT}-${BUILD_NUMBER}/
"""
}
}
}
}
}
}
stage('Build bindings') {
when {
beforeAgent true
expression { return params.bindings }
}
parallel {
stage('Linux bindings') {
when {
beforeAgent true
expression { return params.x86_64_linux }
}
agent { label 'x86_64' }
environment {
JAVA_HOME = "/usr/lib/jvm/java-8-oracle"
}
steps {
script {
def bindings = load ".jenkinsci/bindings.groovy"
def dPullOrBuild = load ".jenkinsci/docker-pull-or-build.groovy"
def platform = sh(script: 'uname -m', returnStdout: true).trim()
def iC = dPullOrBuild.dockerPullOrUpdate(
"$platform-develop-build",
"${GIT_RAW_BASE_URL}/${GIT_COMMIT}/docker/develop/Dockerfile",
"${GIT_RAW_BASE_URL}/${GIT_PREVIOUS_COMMIT}/docker/develop/Dockerfile",
"${GIT_RAW_BASE_URL}/develop/docker/develop/Dockerfile",
['PARALLELISM': params.PARALLELISM])
if (params.JavaBindings) {
iC.inside() {
bindings.doJavaBindings('linux', params.JBPackageName, params.JBBuildType)
}
}
if (params.Python2Bindings) {
iC.inside() {
bindings.doPythonBindings('2', 'linux', params.PBBuildType)
}
}
if (params.Python3Bindings) {
iC.inside() {
bindings.doPythonBindings('3', 'linux', params.PBBuildType)
}
}
}
}
post {
success {
script {
def artifacts = load ".jenkinsci/artifacts.groovy"
if (params.JavaBindings) {
javaBindingsFilePaths = [ 'java-bindings-*.zip' ]
artifacts.uploadArtifacts(javaBindingsFilePaths, 'libiroha/bindings/java')
}
if (params.Python2Bindings || params.Python3Bindings) {
pythonBindingsFilePaths = [ 'python-bindings-*.zip' ]
artifacts.uploadArtifacts(pythonBindingsFilePaths, 'libiroha/bindings/python')
}
}
}
cleanup {
sh "rm -rf /tmp/${GIT_COMMIT}"
cleanWs()
}
}
}
stage ('Windows bindings') {
when {
beforeAgent true
expression { return params.x86_64_win }
}
agent { label 'win' }
steps {
script {
def bindings = load ".jenkinsci/bindings.groovy"
if (params.JavaBindings) {
bindings.doJavaBindings('windows', params.JBPackageName, params.JBBuildType)
}
if (params.Python2Bindings) {
bindings.doPythonBindings('windows', params.PBBuildType)
}
if (params.Python3Bindings) {
bindings.doPythonBindings('windows', params.PBBuildType)
}
}
}
post {
success {
script {
def artifacts = load ".jenkinsci/artifacts.groovy"
if (params.JavaBindings) {
javaBindingsFilePaths = [ 'java-bindings-*.zip' ]
artifacts.uploadArtifacts(javaBindingsFilePaths, 'libiroha/bindings/java')
}
if (params.Python2Bindings || params.Python2Bindings) {
pythonBindingsFilePaths = [ 'python-bindings-*.zip' ]
artifacts.uploadArtifacts(pythonBindingsFilePaths, 'libiroha/bindings/python')
}
}
}
cleanup {
sh "rm -rf /tmp/${GIT_COMMIT}"
cleanWs()
}
}
}
}
}
}
}