Repository navigation
Expand file tree
/
Copy pathJenkinsfile
More file actions
298 lines (294 loc) · 13.5 KB
/
Copy pathJenkinsfile
File metadata and controls
298 lines (294 loc) · 13.5 KB
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
@Library('jenkins-shared-libraries') _
def ENV_LOC=[:]
// Per-job NuGet cache root, so concurrent jobs on a node don't contend for
// the shared per-user cache. On Unix the workspace is already per-job, so
// the cache lives inside it; on Windows it is rooted at the drive root
// (like setConanHome) to keep restored package paths under the long-path
// limit.
def setNugetRoot() {
if (isUnix()) {
return "${WORKSPACE}/.nuget"
}
def jobDirectory = "DL\\" + env.JOB_NAME.tokenize('/')[-2] + "_" + env.JOB_BASE_NAME
return getWindowsRootDrive() + jobDirectory + "\\.nuget"
}
def nugetCachePath(String subdir) {
return setNugetRoot() + (isUnix() ? '/' : '\\') + subdir
}
pipeline {
parameters {
choice(name: 'PLATFORM_FILTER', choices: ['all', 'windows-dotnet-samples', 'rocky9-dotnet-samples', 'mac-arm-dotnet-samples', 'mac-intel-dotnet-samples', 'rocky9-arm-dotnet-samples'], description: 'Run on specific platform')
booleanParam defaultValue: false, description: 'Completely clean the workspace before building, including the NuGet cache', name: 'CLEAN_WORKSPACE'
booleanParam defaultValue: false, description: 'Run clean-samples', name: 'DISTCLEAN'
booleanParam defaultValue: true, description: 'Run clean-nuget-cache', name: 'NUGETCLEAN'
}
options{
buildDiscarder logRotator(artifactDaysToKeepStr: '4', artifactNumToKeepStr: '10', daysToKeepStr: '7', numToKeepStr: '10')
disableConcurrentBuilds()
timeout(time: 4, unit: "HOURS")
}
agent none
triggers {
cron(env.BRANCH_NAME == "develop-21" ? '30 7 * * *' : '')
}
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', 'rocky9-dotnet-samples', 'mac-arm-dotnet-samples', 'mac-intel-dotnet-samples','rocky9-arm-dotnet-samples'
}
}
environment {
APDFL_KEY = credentials('apdfl-rlm-key')
// NuGet honors these for restore, build, and
// 'dotnet nuget locals --clear all' alike.
NUGET_ROOT = setNugetRoot()
NUGET_PACKAGES = nugetCachePath('packages')
NUGET_HTTP_CACHE_PATH = nugetCachePath('http-cache')
NUGET_PLUGINS_CACHE_PATH = nugetCachePath('plugins-cache')
}
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 the NuGet cache root lives outside
// the workspace, so git clean can't remove it.
bat """
if exist "%NUGET_ROOT%" rmdir /s /q "%NUGET_ROOT%"
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('Clean Nuget Cache') {
when {
expression {
params.NUGETCLEAN
}
}
steps {
echo "Clean ${NODE}"
script {
if (isUnix()) {
sh """. ${ENV_LOC[NODE]}/bin/activate
invoke clean-nuget-cache
"""
} else {
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke clean-nuget-cache
"""
}
}
}
}
stage('Build Samples using Nightly packages') {
steps {
echo "Build the samples ${NODE}"
script {
if (isUnix()) {
sh """. ${ENV_LOC[NODE]}/bin/activate
invoke build-samples --pkg-source Nightly
"""
} else {
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke build-samples --pkg-source Nightly
"""
}
}
}
}
stage('Run Samples using Nightly packages') {
steps {
echo "Run the samples ${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 Nightly 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
"""
}
}
}
}
stage('Clean Nuget Packages Before Public Build') {
when {
expression {
env.NODE != 'mac-intel-dotnet-samples'
}
}
steps {
echo "Clean ${NODE}"
script {
if (isUnix()) {
sh """. ${ENV_LOC[NODE]}/bin/activate
invoke clean-nuget-packages
"""
} else {
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke clean-nuget-packages
"""
}
}
}
}
stage('Build Samples using Public packages') {
when {
expression {
env.NODE != 'mac-intel-dotnet-samples'
}
}
steps {
echo "Build the samples ${NODE}"
script {
if (isUnix()) {
sh """. ${ENV_LOC[NODE]}/bin/activate
invoke build-samples --pkg-source Public
"""
} else {
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke build-samples --pkg-source Public
"""
}
}
}
}
stage('Run Samples using Public packages') {
when {
expression {
env.NODE != 'mac-intel-dotnet-samples'
}
}
steps {
echo "Run the samples ${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 Public Run') {
when {
expression {
env.NODE != 'mac-intel-dotnet-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
"""
}
}
}
}
}
}
}
}
}