-
Notifications
You must be signed in to change notification settings - Fork 9
/
Jenkinsfile
171 lines (171 loc) · 7.88 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
@Library('jenkins-shared-libraries') _
def ENV_LOC=[:]
pipeline {
parameters {
choice(name: 'PLATFORM_FILTER', choices: ['all', 'windows-dotnet-samples', 'linux-dotnet-samples', 'mac-arm-dotnet-samples', 'mac-intel-dotnet-samples','linux-arm-dotnet-samples'], description: 'Run on specific platform')
booleanParam defaultValue: false, description: 'Completely clean the workspace before building, including the Conan cache', name: 'CLEAN_WORKSPACE'
booleanParam defaultValue: false, description: 'Run clean-samples', name: 'DISTCLEAN'
}
options{
buildDiscarder logRotator(artifactDaysToKeepStr: '4', artifactNumToKeepStr: '10', daysToKeepStr: '7', numToKeepStr: '10')
disableConcurrentBuilds()
timeout(time: 4, unit: "HOURS")
}
agent none
triggers {
// From the doc: @midnight actually means some time between 12:00 AM and 2:59 AM.
// This gives us automatic spreading out of jobs, so they don't cause load spikes.
cron('@midnight')
}
stages {
stage('Matrix stage') {
matrix {
agent {
label "${NODE}"
}
when { anyOf {
expression { params.PLATFORM_FILTER == 'all' }
expression { params.PLATFORM_FILTER == env.NODE }
} }
axes {
axis {
name 'NODE'
values 'windows-dotnet-samples', 'linux-dotnet-samples', 'mac-arm-dotnet-samples', 'mac-intel-dotnet-samples','linux-arm-dotnet-samples'
}
}
environment {
CONAN_USER_HOME = "${WORKSPACE}"
CONAN_NON_INTERACTIVE = '1'
CONAN_PRINT_RUN_COMMANDS = '1'
}
stages {
stage('Axis'){
steps {
printPlatformNameInStep()
}
}
stage('Clean/reset Git checkout for release') {
when {
expression {
params.CLEAN_WORKSPACE
}
}
steps {
echo "Clean ${NODE}"
script {
// Ensure that the checkout is clean and any changes
// to .gitattributes and .gitignore have been taken
// into effect
if (isUnix()) {
sh """
git rm -f -q -r .
git reset --hard HEAD
git clean -fdx
"""
} else {
// On Windows, 'git clean' can't handle long paths in .conan,
// so remove that first.
bat """
if exist ${WORKSPACE}\\.conan\\ rmdir/s/q ${WORKSPACE}\\.conan
git rm -q -r .
git reset --hard HEAD
git clean -fdx
"""
}
}
}
}
stage('Set-Up Environment') {
steps {
echo "Set-Up Environment ${NODE}"
script {
if (isUnix()) {
sh './mkenv.py --verbose'
ENV_LOC[NODE] = sh (
script: './mkenv.py --env-name',
returnStdout: true
).trim()
} else {
// Using the mkenv.py script like this assumes the Python Launcher is
// installed on the Windows host.
// https://docs.python.org/3/using/windows.html#launcher
bat '.\\mkenv.py --verbose'
ENV_LOC[NODE] = bat (
// The @ prevents Windows from echoing the command itself into the stdout,
// which would corrupt the value of the returned data.
script: '@.\\mkenv.py --env-name',
returnStdout: true
).trim()
}
}
}
}
stage('Clean Samples') {
steps {
echo "Clean ${NODE}"
script {
if (isUnix()) {
sh """. ${ENV_LOC[NODE]}/bin/activate
invoke clean-samples
"""
} else {
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke clean-samples
"""
}
}
}
}
stage('Build Samples') {
steps {
echo "Bootstrap ${NODE}"
script {
if (isUnix()) {
sh """. ${ENV_LOC[NODE]}/bin/activate
invoke build-samples
"""
} else {
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke build-samples
"""
}
}
}
}
stage('Run Samples') {
steps {
echo "Show Conan dependencies ${NODE}"
script {
if (isUnix()) {
sh """. ${ENV_LOC[NODE]}/bin/activate
invoke run-samples
"""
} else {
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke run-samples
"""
}
}
}
}
stage('Clean Samples After Run') {
steps {
echo "Clean ${NODE}"
script {
if (isUnix()) {
sh """. ${ENV_LOC[NODE]}/bin/activate
invoke clean-samples
"""
} else {
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke clean-samples
"""
}
}
}
}
}
}
}
}
}