This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
120 lines (94 loc) · 2.63 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
def isWindows(){
//If NODE_LABELS environment variable is null, we assume we are on master unix machine
if (env.NODE_LABELS == null) {
return false
}
return env.NODE_LABELS.toLowerCase().contains('windows')
}
def shell(params){
if(isWindows()) bat(params)
else sh(params)
}
def runInCygwin(command){
def c = """#!c:\\tools\\cygwin\\bin\\bash --login
cd `cygpath \"$WORKSPACE\"`
set -ex
${command}
"""
echo("Executing: ${c}")
withEnv(["PHARO_CI_TESTING_ENVIRONMENT=true"]) {
return sh(c)
}
}
def runBuild(platform){
cleanWs()
stage("Checkout-${platform}"){
checkout scm
}
stage("Build-${platform}"){
if(isWindows()){
runInCygwin "cmake ."
runInCygwin "make install"
g runInCygwin "make package"
}else{
cmakeBuild generator: "Unix Makefiles", sourceDir: ".", installation: "InSearchPath"
shell "make install"
shell "make prepare-tests test"
shell "make package"
}
junit allowEmptyResults: true, testResults: "build/test/*.xml"
stash excludes: '_CPack_Packages', includes: 'build/packages/*', name: "packages-${platform}"
archiveArtifacts artifacts: 'build/packages/*', excludes: '_CPack_Packages'
}
}
def upload(platform, dir, zipPlatformName) {
unstash name: "packages-${platform}"
def expandedFileName = sh(returnStdout: true, script: "ls build/packages/PThreadedFFI*${zipPlatformName}*.zip").trim()
sshagent (credentials: ['b5248b59-a193-4457-8459-e28e9eb29ed7']) {
sh "scp -o StrictHostKeyChecking=no \
${expandedFileName} \
pharoorgde@ssh.cluster023.hosting.ovh.net:/home/pharoorgde/files/vm/pharo-spur64/${dir}/third-party"
}
}
def isPullRequest() {
return env.CHANGE_ID != null
}
def uploadPackages(){
node('unix'){
stage('Upload'){
if (isPullRequest()) {
//Only upload files if not in a PR (i.e., CHANGE_ID not empty)
echo "[DO NO UPLOAD] In PR " + (env.CHANGE_ID?.trim())
return;
}
if(env.TAG_NAME ==~ /v\d+\.\d+\.\d+.*/){
upload('osx', 'mac', 'osx64')
upload('unix', 'linux', 'linux64')
upload('windows', 'win', 'win64')
return;
}
echo "[DO NO UPLOAD] It is not a tag with the form v1.0.0"
}
}
}
try{
properties([disableConcurrentBuilds()])
def platforms = ['unix', 'osx', 'windows']
def builders = [:]
def tests = [:]
for (platf in platforms) {
// Need to bind the label variable before the closure - can't do 'for (label in labels)'
def platform = platf
builders[platform] = {
node(platform){
timeout(30){
runBuild(platform)
}
}
}
}
parallel builders
uploadPackages()
} catch (e) {
throw e
}