Repository navigation
Expand file tree
/
Copy pathJenkinsfile
More file actions
186 lines (183 loc) · 8.23 KB
/
Copy pathJenkinsfile
File metadata and controls
186 lines (183 loc) · 8.23 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
@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. Rooted at the drive root (like setConanHome)
// to keep restored package paths under the Windows long-path limit.
def setNugetRoot() {
def jobDirectory = "DL\\" + env.JOB_NAME.tokenize('/')[-2] + "_" + env.JOB_BASE_NAME
return getWindowsRootDrive() + jobDirectory + "\\.nuget"
}
pipeline {
parameters {
choice(name: 'PLATFORM_FILTER', choices: ['all', 'windows-dotnet-framework-samples'], description: 'Run on specific platform')
booleanParam defaultValue: false, description: 'Completely clean the workspace before building', 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 5 * * *' : '')
}
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-framework-samples'
}
}
environment {
APDFL_KEY = credentials('apdfl-rlm-key')
// NuGet honors these for restore, msbuild, and
// 'nuget locals all -clear' alike.
NUGET_ROOT = setNugetRoot()
NUGET_PACKAGES = "${NUGET_ROOT}\\packages"
NUGET_HTTP_CACHE_PATH = "${NUGET_ROOT}\\http-cache"
NUGET_PLUGINS_CACHE_PATH = "${NUGET_ROOT}\\plugins-cache"
}
stages {
stage('Axis'){
steps {
printPlatformNameInStep()
}
}
stage('Clean/reset Git checkout for release') {
when {
expression {
params.CLEAN_WORKSPACE
}
}
steps {
echo "Clean ${NODE}"
// 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 {
// Assumes the Python Launcher is installed on the Windows host.
// Invoke py.exe directly rather than relying on the .py file
// association: a per-user association (e.g. one created by
// Explorer's "Open with") can drop the script's arguments.
bat 'py -3 mkenv.py --verbose'
ENV_LOC[NODE] = bat (
// The @ prevents Windows from echoing the command itself,
// which would corrupt the returned value.
script: '@py -3 mkenv.py --env-name',
returnStdout: true
).trim()
}
}
}
stage('Clean Samples') {
steps {
echo "Clean ${NODE}"
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke clean-samples
"""
}
}
stage('Clean Nuget Cache') {
when {
expression {
params.NUGETCLEAN
}
}
steps {
echo "Clean ${NODE}"
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke clean-nuget-cache
"""
}
}
stage('Build Samples using Nightly packages') {
steps {
echo "Build the samples ${NODE}"
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}"
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke run-samples
"""
}
}
stage('Clean Samples After Nightly Run') {
steps {
echo "Clean ${NODE}"
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke clean-samples
"""
}
}
stage('Clean Nuget Packages Before Public Build') {
steps {
echo "Clean ${NODE}"
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke clean-nuget-packages
"""
}
}
stage('Build Samples using Public packages') {
steps {
echo "Build the samples ${NODE}"
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke build-samples --pkg-source Public
"""
}
}
stage('Run Samples using Public packages') {
steps {
echo "Run the samples ${NODE}"
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke run-samples
"""
}
}
}
post {
// Runs whether or not an earlier stage failed. Each sample's
// bin holds its own copy of the APDFL runtime, so leaving them
// behind after a failed build or run fills the node's disk
// until the next job happens to clean them.
cleanup {
script {
if (ENV_LOC[NODE]) {
bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate
invoke clean-samples
"""
} else {
echo "No Python environment on ${NODE}, so nothing was built; skipping clean-samples"
}
}
}
}
}
}
}
}