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.1
171 lines (166 loc) · 7.53 KB
/
Jenkinsfile.1
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
properties([parameters([
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: true, 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 Python bindings', name: 'PythonBindings'),
choice(choices: 'Release\nDebug', description: 'Python bindings build type', name: 'PBBuildType'),
choice(choices: 'python3\npython2', description: 'Python bindings version', name: 'PBVersion'),
booleanParam(defaultValue: true, description: 'Build Android bindings', name: 'AndroidBindings'),
choice(choices: '26\n25\n24\n23\n22\n21\n20\n19\n18\n17\n16\n15\n14', description: 'Android Bindings ABI Version', name: 'ABABIVersion'),
choice(choices: 'Release\nDebug', description: 'Android bindings build type', name: 'ABBuildType'),
choice(choices: 'arm64-v8a\narmeabi-v7a\narmeabi\nx86_64\nx86', description: 'Android bindings platform', name: 'ABPlatform'),
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/iroha"
DOCKER_REGISTRY_BASENAME = "hyperledger/iroha"
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 = env.CHANGE_BRANCH
}
catch(MissingPropertyException e) { }
if (env.GIT_LOCAL_BRANCH != "develop" && env.CHANGE_BRANCH_LOCAL != "develop") {
def builds = load ".jenkinsci/cancel-builds-same-job.groovy"
builds.cancelSameJobBuilds()
}
}
}
}
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()
if (params.JavaBindings || params.PythonBindings) {
def iC = docker.image("${DOCKER_REGISTRY_BASENAME}:${$platform}-develop-build")
if (params.JavaBindings) {
iC.inside("-v /tmp/${env.GIT_COMMIT}/bindings-artifact:/tmp/bindings-artifact") {
bindings.doJavaBindings('linux', params.JBPackageName, params.JBBuildType)
}
}
if (params.PythonBindings) {
iC.inside("-v /tmp/${env.GIT_COMMIT}/bindings-artifact:/tmp/bindings-artifact") {
bindings.doPythonBindings('linux', params.PBBuildType)
}
}
}
if (params.AndroidBindings) {
def iC = docker.image("${DOCKER_REGISTRY_BASENAME}:android-${params.ABPlatform}-${params.ABBuildType}")
sh "curl -L -o /tmp/${env.GIT_COMMIT}/entrypoint.sh ${env.GIT_RAW_BASE_URL}/${env.GIT_COMMIT}/docker/android/entrypoint.sh"
sh "chmod +x /tmp/${env.GIT_COMMIT}/entrypoint.sh"
iC.inside("-v /tmp/${env.GIT_COMMIT}/entrypoint.sh:/entrypoint.sh:ro -v /tmp/${env.GIT_COMMIT}/bindings-artifact:/tmp/bindings-artifact") {
bindings.doAndroidBindings(params.ABABIVersion)
}
}
}
}
post {
success {
script {
def artifacts = load ".jenkinsci/artifacts.groovy"
def commit = env.GIT_COMMIT
if (params.JavaBindings) {
javaBindingsFilePaths = [ '/tmp/${GIT_COMMIT}/bindings-artifact/java-bindings-*.zip' ]
artifacts.uploadArtifacts(javaBindingsFilePaths, '/iroha/bindings/java')
}
if (params.PythonBindings) {
pythonBindingsFilePaths = [ '/tmp/${GIT_COMMIT}/bindings-artifact/python-bindings-*.zip' ]
artifacts.uploadArtifacts(pythonBindingsFilePaths, '/iroha/bindings/python')
}
if (params.AndroidBindings) {
androidBindingsFilePaths = [ '/tmp/${GIT_COMMIT}/bindings-artifact/android-bindings-*.zip' ]
artifacts.uploadArtifacts(androidBindingsFilePaths, '/iroha/bindings/android')
}
}
}
cleanup {
sh "rm -rf /tmp/${env.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.PythonBindings) {
bindings.doPythonBindings('windows', params.PBBuildType)
}
}
}
post {
success {
script {
def artifacts = load ".jenkinsci/artifacts.groovy"
def commit = env.GIT_COMMIT
if (params.JavaBindings) {
javaBindingsFilePaths = [ '/tmp/${GIT_COMMIT}/bindings-artifact/java-bindings-*.zip' ]
artifacts.uploadArtifacts(javaBindingsFilePaths, '/iroha/bindings/java')
}
if (params.PythonBindings) {
pythonBindingsFilePaths = [ '/tmp/${GIT_COMMIT}/bindings-artifact/python-bindings-*.zip' ]
artifacts.uploadArtifacts(pythonBindingsFilePaths, '/iroha/bindings/python')
}
}
}
cleanup {
sh "rm -rf /tmp/${env.GIT_COMMIT}"
cleanWs()
}
}
}
}
}
}
}