forked from VirgilSecurity/virgil-crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
260 lines (244 loc) · 11.4 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!groovy
stage 'Grab SCM'
node('master') {
clearContentUnix()
checkout scm
sh 'mkdir -p install'
sh 'cp -f VERSION install/'
archiveArtifacts('install/VERSION')
stash includes: '**', name: 'src'
}
stage 'Build'
def slaves = [:]
slaves['native-centos7'] = createNativeUnixBuild('build-centos7');
slaves['native-os-x'] = createNativeUnixBuild('build-os-x');
slaves['native-win8'] = createNativeWindowsBuild('build-win8');
slaves['crossplatform'] = createCrossplatfromBuild('build-os-x');
slaves['darwin'] = createDarwinBuild('build-os-x');
slaves['android'] = createAndroidBuild('build-os-x');
parallel slaves
stage 'Fingerprint'
node('master') {
def branchSubPath = env.BRANCH_NAME ? '/branches/' + env.BRANCH_NAME : ''
def shortJobName = env.BRANCH_NAME ? env.JOB_NAME.replace('/' + env.BRANCH_NAME, '') : env.JOB_NAME
def artifactsDir =
env.JENKINS_HOME + '/jobs/' + shortJobName + branchSubPath + '/builds/' + env.BUILD_NUMBER + '/archive'
dir(artifactsDir) {
sh 'find . -type f -name "virgil-crypto-*" -exec sh -c "sha256sum {} | cut -d\' \' -f1-1 > {}.sha256" \\;'
}
}
def createNativeUnixBuild(slave) {
return {
node(slave) {
clearContentUnix()
unstash 'src'
// C++
sh './utils/build.sh --target=cpp'
// Ruby
withEnv(["PATH=${env.HOME}/.rbenv/bin:${env.PATH}"]){
writeFile file: './utils/env.sh', text: ['eval "$(rbenv init -)"'].join("\n")
writeFile file: '.ruby-version', text: ['2.0.0-p648'].join("\n")
sh './utils/build.sh --target=ruby-2.0'
writeFile file: '.ruby-version', text: ['2.2.6'].join("\n")
sh './utils/build.sh --target=ruby-2.2'
writeFile file: '.ruby-version', text: ['2.3.3'].join("\n")
sh './utils/build.sh --target=ruby-2.3'
writeFile file: '.ruby-version', text: ['2.4.0'].join("\n")
sh './utils/build.sh --target=ruby-2.4'
}
organizeFilesUnix('install/ruby')
// Python
if (slave.contains('centos7')) {
sh './utils/build.sh --target=python-2.7'
writeFile file: './utils/env.sh', text: ['source /opt/rh/python33/enable', ''].join("\n")
sh './utils/build.sh --target=python-3.3'
writeFile file: './utils/env.sh', text: ['source /opt/rh/rh-python34/enable', ''].join("\n")
sh './utils/build.sh --target=python-3.4'
writeFile file: './utils/env.sh', text: ['source /opt/rh/rh-python35/enable', ''].join("\n")
sh './utils/build.sh --target=python-3.5'
writeFile file: './utils/env.sh', text: ['source /opt/rh/rh-python36/enable', ''].join("\n")
sh './utils/build.sh --target=python-3.6'
organizeFilesUnix('install/python')
}
if (slave.contains('build-os-x')) {
sh './utils/build.sh --target=python-2.7'
sh './utils/build.sh --target=python-3.4'
sh './utils/build.sh --target=python-3.5'
sh './utils/build.sh --target=python-3.6'
organizeFilesUnix('install/python')
}
// Java
sh './utils/build.sh --target=java'
// NodeJS
sh './utils/build.sh --target=nodejs-4.9.1'
sh './utils/build.sh --target=nodejs-6.14.2'
sh './utils/build.sh --target=nodejs-7.10.1'
sh './utils/build.sh --target=nodejs-8.11.2'
sh './utils/build.sh --target=nodejs-9.11.1'
sh './utils/build.sh --target=nodejs-10.1.0'
organizeFilesUnix('install/nodejs')
// PHP
if (slave.contains('os-x')) {
def phpVersions = "php56 php70 php71 php72"
sh "brew unlink ${phpVersions} && brew link php56 --force"
sh "./utils/build.sh --target=php-5.6"
sh "brew unlink ${phpVersions} && brew link php70 --force"
sh "./utils/build.sh --target=php-7.0"
sh "brew unlink ${phpVersions} && brew link php71 --force"
sh "./utils/build.sh --target=php-7.1"
sh "brew unlink ${phpVersions} && brew link php72 --force"
sh "./utils/build.sh --target=php-7.2"
organizeFilesUnix('install/php')
}
if (slave.contains('centos7')) {
writeFile file: './utils/env.sh', text: ['source /opt/rh/rh-php56/enable', ''].join("\n")
sh './utils/build.sh --target=php-5.6'
writeFile file: './utils/env.sh', text: ['source /opt/rh/rh-php70/enable', ''].join("\n")
sh './utils/build.sh --target=php-7.0'
writeFile file: './utils/env.sh', text: ['source /opt/remi/php71/enable', ''].join("\n")
sh './utils/build.sh --target=php-7.1'
writeFile file: './utils/env.sh', text: ['source /opt/remi/php72/enable', 'source /opt/rh/devtoolset-4/enable', ''].join("\n")
sh './utils/build.sh --target=php-7.2'
organizeFilesUnix('install/php')
}
// MONO NET
sh './utils/build.sh --target=net'
// Golang
if (slave.contains('centos7') || slave.contains('os-x')) {
sh './utils/build.sh --target=go'
}
archiveArtifacts('install/**')
}
}
}
def createNativeWindowsBuild(slave) {
return {
node(slave) {
clearContentWindows()
unstash 'src'
withEnv(['MSVC_ROOT=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0',
'JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_65']) {
bat 'utils\\build.bat cpp'
bat 'utils\\build.bat net'
bat 'utils\\build.bat java'
bat 'utils\\build.bat nodejs-4.9.1'
bat 'utils\\build.bat nodejs-6.14.3'
bat 'utils\\build.bat nodejs-7.10.1'
bat 'utils\\build.bat nodejs-8.11.3'
bat 'utils\\build.bat nodejs-9.11.2'
bat 'utils\\build.bat nodejs-10.4.1'
withEnv(["PATH=C:\\Python27_x86;${env.PATH}"]) {
bat 'utils\\build.bat python-2.7-x86'
}
withEnv(["PATH=C:\\Python27_x64;${env.PATH}"]) {
bat 'utils\\build.bat python-2.7-x64'
}
withEnv(["PATH=C:\\Python33_x86;${env.PATH}"]) {
bat 'utils\\build.bat python-3.3-x86'
}
withEnv(["PATH=C:\\Python33_x64;${env.PATH}"]) {
bat 'utils\\build.bat python-3.3-x64'
}
withEnv(["PATH=C:\\Python34_x86;${env.PATH}"]) {
bat 'utils\\build.bat python-3.4-x86'
}
withEnv(["PATH=C:\\Python34_x64;${env.PATH}"]) {
bat 'utils\\build.bat python-3.4-x64'
}
withEnv(["PATH=C:\\Python35_x86;${env.PATH}"]) {
bat 'utils\\build.bat python-3.5-x86'
}
withEnv(["PATH=C:\\Python35_x64;${env.PATH}"]) {
bat 'utils\\build.bat python-3.5-x64'
}
withEnv(["PATH=C:\\Python36_x86;${env.PATH}"]) {
bat 'utils\\build.bat python-3.6-x86'
}
withEnv(["PATH=C:\\Python36_x64;${env.PATH}"]) {
bat 'utils\\build.bat python-3.6-x64'
}
}
withEnv(["MSVC_ROOT=C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community",
"PHP_HOME=C:\\php-7.2.6",
"PHP_DEVEL_HOME=C:\\php-7.2.6-devel",\
"PHPUNIT_HOME=C:\\phpunit-7.2.4"]) {
bat 'utils\\build.bat php-7.2-x64'
}
organizeFilesWindows('install\\cpp')
organizeFilesWindows('install\\net')
organizeFilesWindows('install\\java')
organizeFilesWindows('install\\nodejs')
organizeFilesWindows('install\\python')
organizeFilesWindows('install\\php')
archiveArtifacts('install/**')
}
}
}
def createCrossplatfromBuild(slave) {
return {
node(slave) {
clearContentUnix()
unstash 'src'
withEnv(['EMSDK_HOME=/Users/virgil/Library/VirgilEnviroment/emsdk_portable']) {
sh './utils/build.sh --target=asmjs --build=build/asmjs/basic --install=install/asmjs/basic'
sh './utils/build.sh --target=asmjs --build=build/asmjs/pythia --install=install/asmjs/pythia --feature=pythia'
sh './utils/build.sh --target=webasm --build=build/webasm/basic --install=install/webasm/basic'
sh './utils/build.sh --target=webasm --build=build/webasm/pythia --install=install/webasm/pythia --feature=pythia'
}
organizeFilesUnix('install/asmjs')
organizeFilesUnix('install/webasm')
archiveArtifacts('install/**')
}
}
}
def createDarwinBuild(slave) {
return {
node(slave) {
clearContentUnix()
unstash 'src'
sh 'rm -fr build install'
sh './utils/build.sh --target=macos --build=build/cpp/macos --install=install/cpp/macos'
sh './utils/build.sh --target=ios --build=build/cpp/ios --install=install/cpp/ios '
sh './utils/build.sh --target=watchos --build=build/cpp/watchos --install=install/cpp/watchos'
sh './utils/build.sh --target=tvos --build=build/cpp/tvos --install=install/cpp/tvos'
sh './utils/build.sh --target=net_ios --build=build/net/ios --install=install/net/ios'
sh './utils/build.sh --target=net_watchos --build=build/net/watchos --install=install/net/watchos'
sh './utils/build.sh --target=net_tvos --build=build/net/tvos --install=install/net/tvos'
organizeFilesUnix('install/cpp')
organizeFilesUnix('install/net')
archiveArtifacts('install/**')
}
}
}
def createAndroidBuild(slave) {
return {
node(slave) {
clearContentUnix()
unstash 'src'
withEnv(['ANDROID_NDK=/Users/virgil/Library/VirgilEnviroment/android-ndk-r16b']) {
sh './utils/build.sh --target=java_android --build=build/java/android --install=install/java/android'
sh './utils/build.sh --target=net_android --build=build/net/android --install=install/net/android'
}
organizeFilesUnix('install/java')
organizeFilesUnix('install/net')
archiveArtifacts('install/**')
}
}
}
def organizeFilesUnix(where) {
sh "find ${where} -type f -mindepth 2 -name \"*.tgz\" -exec mv {} ${where} \\;"
sh "find ${where} -type d -empty -delete"
}
def organizeFilesWindows(where) {
bat "for /r \"${where}\" %%f in (*.zip) do move /y \"%%f\" \"${where}\""
bat "(for /f \"delims=\" %%d in ('dir /s /b /a:d \"${where}\" ^^^| sort /r') do rmdir \"%%d\") || rem"
}
def clearContentWindows() {
bat "(for /F \"delims=\" %%i in ('dir /b') do (rmdir \"%%i\" /s/q >nul 2>&1 || del \"%%i\" /s/q >nul 2>&1 )) || rem"
}
def clearContentUnix() {
sh "rm -fr -- *"
}
def archiveArtifacts(pattern) {
step([$class: 'ArtifactArchiver', artifacts: pattern, fingerprint: true, onlyIfSuccessful: true])
}