Restore Windows arm32/arm64 innerloop build jobs
[platform/upstream/coreclr.git] / netci.groovy
1 // Import the utility functionality.
2
3 import jobs.generation.*
4
5 // The input project name (e.g. dotnet/coreclr)
6 def project = GithubProject
7 // The input branch name (e.g. master)
8 def branch = GithubBranchName
9 def projectFolder = Utilities.getFolderName(project) + '/' + Utilities.getFolderName(branch)
10
11 // Create a folder for JIT stress jobs and associated folder views
12 folder('jitstress')
13 Utilities.addStandardFolderView(this, 'jitstress', project)
14
15 // Create a folder for testing via illink
16 folder('illink')
17 Utilities.addStandardFolderView(this, 'illink', project)
18
19 def static getOSGroup(def os) {
20     def osGroupMap = ['Ubuntu'      : 'Linux',
21                       'Ubuntu16.04' : 'Linux',
22                       'Ubuntu16.10' : 'Linux',
23                       'RHEL7.2'     : 'Linux',
24                       'Debian8.4'   : 'Linux',
25                       'Fedora24'    : 'Linux',
26                       'CentOS7.1'   : 'Linux',
27                       'Tizen'       : 'Linux',
28                       'OSX10.12'    : 'OSX',
29                       'Windows_NT'  : 'Windows_NT']
30     def osGroup = osGroupMap.get(os, null)
31     assert osGroup != null : "Could not find os group for ${os}"
32     return osGroupMap[os]
33 }
34
35 // We use this class (vs variables) so that the static functions can access data here.
36 class Constants {
37
38     // We have very limited Windows ARM64 hardware (used for ARM/ARM64 testing) and Linux/arm32 and Linux/arm64 hardware.
39     // So only allow certain branches to use it.
40     def static LimitedHardwareBranches = [
41                'master']
42
43     // Innerloop build OS's
44     // The Windows_NT_BuildOnly OS is a way to speed up the Non-Windows builds by avoiding
45     // test execution in the build flow runs.  It generates the exact same build
46     // as Windows_NT but without running the tests.
47     def static osList = [
48                'Ubuntu',
49                'Debian8.4',
50                'OSX10.12',
51                'Windows_NT',
52                'Windows_NT_BuildOnly',
53                'CentOS7.1',
54                'RHEL7.2',
55                'Ubuntu16.04',
56                'Ubuntu16.10',
57                'Fedora24',
58                'Tizen']
59
60     def static crossList = [
61                'Ubuntu',
62                'Debian8.4',
63                'OSX10.12',
64                'Windows_NT',
65                'CentOS7.1',
66                'RHEL7.2']
67
68     // This is a set of JIT stress modes combined with the set of variables that
69     // need to be set to actually enable that stress mode.  The key of the map is the stress mode and
70     // the values are the environment variables
71     def static jitStressModeScenarios = [
72                'minopts'                        : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JITMinOpts' : '1'],
73                'tieredcompilation'              : ['COMPlus_TieredCompilation' : '1'], // this can be removed once tiered compilation is on by default
74                'no_tiered_compilation'          : ['COMPlus_TieredCompilation' : '0'],
75                'no_tiered_compilation_innerloop': ['COMPlus_TieredCompilation' : '0'],
76                'forcerelocs'                    : ['COMPlus_TieredCompilation' : '0', 'COMPlus_ForceRelocs' : '1'],
77                'jitstress1'                     : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '1'],
78                'jitstress2'                     : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2'],
79                'jitstress1_tiered'              : ['COMPlus_TieredCompilation' : '1', 'COMPlus_JitStress' : '1'],
80                'jitstress2_tiered'              : ['COMPlus_TieredCompilation' : '1', 'COMPlus_JitStress' : '2'],
81                'jitstressregs1'                 : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '1'],
82                'jitstressregs2'                 : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '2'],
83                'jitstressregs3'                 : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '3'],
84                'jitstressregs4'                 : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '4'],
85                'jitstressregs8'                 : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '8'],
86                'jitstressregs0x10'              : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x10'],
87                'jitstressregs0x80'              : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x80'],
88                'jitstressregs0x1000'            : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x1000'],
89                'jitstress2_jitstressregs1'      : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '1'],
90                'jitstress2_jitstressregs2'      : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '2'],
91                'jitstress2_jitstressregs3'      : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '3'],
92                'jitstress2_jitstressregs4'      : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '4'],
93                'jitstress2_jitstressregs8'      : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '8'],
94                'jitstress2_jitstressregs0x10'   : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '0x10'],
95                'jitstress2_jitstressregs0x80'   : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '0x80'],
96                'jitstress2_jitstressregs0x1000' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '0x1000'],
97                'tailcallstress'                 : ['COMPlus_TieredCompilation' : '0', 'COMPlus_TailcallStress' : '1'],
98                'jitsse2only'                    : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableAVX' : '0', 'COMPlus_EnableSSE3_4' : '0'],
99                'jitnosimd'                      : ['COMPlus_TieredCompilation' : '0', 'COMPlus_FeatureSIMD' : '0'],
100                'jitincompletehwintrinsic'       : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableIncompleteISAClass' : '1'],
101                'jitx86hwintrinsicnoavx'         : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_EnableAVX' : '0'], // testing the legacy SSE encoding
102                'jitx86hwintrinsicnoavx2'        : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_EnableAVX2' : '0'], // testing SNB/IVB
103                'jitx86hwintrinsicnosimd'        : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_FeatureSIMD' : '0'], // match "jitnosimd", may need to remove after decoupling HW intrinsic from FeatureSIMD
104                'jitnox86hwintrinsic'            : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_EnableSSE' : '0' , 'COMPlus_EnableSSE2' : '0' , 'COMPlus_EnableSSE3' : '0' , 'COMPlus_EnableSSSE3' : '0' , 'COMPlus_EnableSSE41' : '0' , 'COMPlus_EnableSSE42' : '0' , 'COMPlus_EnableAVX' : '0' , 'COMPlus_EnableAVX2' : '0' , 'COMPlus_EnableAES' : '0' , 'COMPlus_EnableBMI1' : '0' , 'COMPlus_EnableBMI2' : '0' , 'COMPlus_EnableFMA' : '0' , 'COMPlus_EnableLZCNT' : '0' , 'COMPlus_EnablePCLMULQDQ' : '0' , 'COMPlus_EnablePOPCNT' : '0'],
105                'corefx_baseline'                : ['COMPlus_TieredCompilation' : '0'], // corefx baseline
106                'corefx_minopts'                 : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JITMinOpts' : '1'],
107                'corefx_tieredcompilation'       : ['COMPlus_TieredCompilation' : '1'],  // this can be removed once tiered compilation is on by default
108                'corefx_jitstress1'              : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '1'],
109                'corefx_jitstress2'              : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2'],
110                'corefx_jitstressregs1'          : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '1'],
111                'corefx_jitstressregs2'          : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '2'],
112                'corefx_jitstressregs3'          : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '3'],
113                'corefx_jitstressregs4'          : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '4'],
114                'corefx_jitstressregs8'          : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '8'],
115                'corefx_jitstressregs0x10'       : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x10'],
116                'corefx_jitstressregs0x80'       : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x80'],
117                'corefx_jitstressregs0x1000'     : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x1000'],
118                'gcstress0x3'                    : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0x3'],
119                'gcstress0xc'                    : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC'],
120                'zapdisable'                     : ['COMPlus_TieredCompilation' : '0', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0'],
121                'heapverify1'                    : ['COMPlus_TieredCompilation' : '0', 'COMPlus_HeapVerify' : '1'],
122                'gcstress0xc_zapdisable'             : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0'],
123                'gcstress0xc_zapdisable_jitstress2'  : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0', 'COMPlus_JitStress'  : '2'],
124                'gcstress0xc_zapdisable_heapverify1' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0', 'COMPlus_HeapVerify' : '1'],
125                'gcstress0xc_jitstress1'             : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_JitStress'  : '1'],
126                'gcstress0xc_jitstress2'             : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_JitStress'  : '2'],
127                'gcstress0xc_minopts_heapverify1'    : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_JITMinOpts' : '1', 'COMPlus_HeapVerify' : '1']
128     ]
129
130     // This is a set of ReadyToRun stress scenarios
131     def static r2rStressScenarios = [
132                'r2r_jitstress1'             : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStress": "1"],
133                'r2r_jitstress2'             : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStress": "2"],
134                'r2r_jitstress1_tiered'      : ['COMPlus_TieredCompilation' : '1', "COMPlus_JitStress": "1"],
135                'r2r_jitstress2_tiered'      : ['COMPlus_TieredCompilation' : '1', "COMPlus_JitStress": "2"],
136                'r2r_jitstressregs1'         : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "1"],
137                'r2r_jitstressregs2'         : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "2"],
138                'r2r_jitstressregs3'         : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "3"],
139                'r2r_jitstressregs4'         : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "4"],
140                'r2r_jitstressregs8'         : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "8"],
141                'r2r_jitstressregs0x10'      : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "0x10"],
142                'r2r_jitstressregs0x80'      : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "0x80"],
143                'r2r_jitstressregs0x1000'    : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "0x1000"],
144                'r2r_jitminopts'             : ['COMPlus_TieredCompilation' : '0', "COMPlus_JITMinOpts": "1"], 
145                'r2r_jitforcerelocs'         : ['COMPlus_TieredCompilation' : '0', "COMPlus_ForceRelocs": "1"],
146                'r2r_gcstress15'             : ['COMPlus_TieredCompilation' : '0', "COMPlus_GCStress": "0xF"],
147                'r2r_no_tiered_compilation'  : ['COMPlus_TieredCompilation' : '0'],
148     ]
149
150     // This is the basic set of scenarios
151     def static basicScenarios = [
152                'innerloop',
153                'normal',
154                'ilrt',
155                'r2r',
156                'longgc',
157                'formatting',
158                'gcsimulator',
159                // 'jitdiff', // jitdiff is currently disabled, until someone spends the effort to make it fully work
160                'standalone_gc',
161                'gc_reliability_framework',
162                'illink',
163                'corefx_innerloop',
164                'crossgen_comparison',
165                'pmi_asm_diffs']
166
167     def static allScenarios = basicScenarios + r2rStressScenarios.keySet() + jitStressModeScenarios.keySet()
168
169     // Valid PR trigger combinations.
170     def static prTriggeredValidInnerLoopCombos = [
171         'Windows_NT': [
172             'arm': [
173                 'Checked'
174             ],
175             'arm64': [
176                 'Checked'
177             ]
178         ],
179         'Windows_NT_BuildOnly': [
180             'arm': [
181                 'Checked'
182             ], 
183         ]
184     ]
185
186     // A set of scenarios that are valid for arm/arm64 tests run on hardware. This is a map from valid scenario name
187     // to Tests.lst file categories to exclude.
188     //
189     // This list should contain a subset of the scenarios from `allScenarios`. Please keep this in the same order as that,
190     // and with the same values, with some commented out, for easier maintenance.
191     //
192     // Note that some scenarios that are commented out should be enabled, but haven't yet been.
193     //
194     def static validArmWindowsScenarios = [
195                'innerloop',
196                'normal',
197                // 'ilrt'
198                'r2r',
199                // 'longgc'
200                // 'formatting'
201                // 'gcsimulator'
202                // 'jitdiff'
203                // 'standalone_gc'
204                // 'gc_reliability_framework'
205                // 'illink'
206                // 'corefx_innerloop'
207                // 'crossgen_comparison'
208                // 'pmi_asm_diffs'
209                'r2r_jitstress1',
210                'r2r_jitstress2',
211                'r2r_jitstress1_tiered',
212                'r2r_jitstress2_tiered',
213                'r2r_jitstressregs1',
214                'r2r_jitstressregs2',
215                'r2r_jitstressregs3',
216                'r2r_jitstressregs4',
217                'r2r_jitstressregs8',
218                'r2r_jitstressregs0x10',
219                'r2r_jitstressregs0x80',
220                'r2r_jitstressregs0x1000',
221                'r2r_jitminopts',
222                'r2r_jitforcerelocs',
223                'r2r_gcstress15',
224                'r2r_no_tiered_compilation',
225                'minopts',
226                'tieredcompilation',
227                'no_tiered_compilation',
228                'no_tiered_compilation_innerloop',
229                'forcerelocs',
230                'jitstress1',
231                'jitstress2',
232                'jitstress1_tiered',
233                'jitstress2_tiered',
234                'jitstressregs1',
235                'jitstressregs2',
236                'jitstressregs3',
237                'jitstressregs4',
238                'jitstressregs8',
239                'jitstressregs0x10',
240                'jitstressregs0x80',
241                'jitstressregs0x1000',
242                'jitstress2_jitstressregs1',
243                'jitstress2_jitstressregs2',
244                'jitstress2_jitstressregs3',
245                'jitstress2_jitstressregs4',
246                'jitstress2_jitstressregs8',
247                'jitstress2_jitstressregs0x10',
248                'jitstress2_jitstressregs0x80',
249                'jitstress2_jitstressregs0x1000',
250                'tailcallstress',
251                // 'jitsse2only'                     // Only relevant to xarch
252                'jitnosimd',                         // Only interesting on platforms where SIMD support exists.
253                // 'jitincompletehwintrinsic'
254                // 'jitx86hwintrinsicnoavx'
255                // 'jitx86hwintrinsicnoavx2'
256                // 'jitx86hwintrinsicnosimd'
257                // 'jitnox86hwintrinsic'
258                'corefx_baseline',                   // corefx tests don't use smarty
259                'corefx_minopts',                    // corefx tests don't use smarty
260                'corefx_tieredcompilation',          // corefx tests don't use smarty
261                'corefx_jitstress1',                 // corefx tests don't use smarty
262                'corefx_jitstress2',                 // corefx tests don't use smarty
263                'corefx_jitstressregs1',             // corefx tests don't use smarty
264                'corefx_jitstressregs2',             // corefx tests don't use smarty
265                'corefx_jitstressregs3',             // corefx tests don't use smarty
266                'corefx_jitstressregs4',             // corefx tests don't use smarty
267                'corefx_jitstressregs8',             // corefx tests don't use smarty
268                'corefx_jitstressregs0x10',          // corefx tests don't use smarty
269                'corefx_jitstressregs0x80',          // corefx tests don't use smarty
270                'corefx_jitstressregs0x1000',        // corefx tests don't use smarty
271                'gcstress0x3',
272                'gcstress0xc',
273                'zapdisable',
274                'heapverify1',
275                'gcstress0xc_zapdisable',
276                'gcstress0xc_zapdisable_jitstress2',
277                'gcstress0xc_zapdisable_heapverify1',
278                'gcstress0xc_jitstress1',
279                'gcstress0xc_jitstress2',
280                'gcstress0xc_minopts_heapverify1',
281
282                //
283                // NOTE: the following scenarios are not defined in the 'allScenarios' list! Is this a bug?
284                //
285
286                'minopts_zapdisable',
287                'gcstress0x3_jitstress1',
288                'gcstress0x3_jitstress2',
289                'gcstress0x3_jitstressregs1',
290                'gcstress0x3_jitstressregs2',
291                'gcstress0x3_jitstressregs3',
292                'gcstress0x3_jitstressregs4',
293                'gcstress0x3_jitstressregs8',
294                'gcstress0x3_jitstressregs0x10',
295                'gcstress0x3_jitstressregs0x80',
296                'gcstress0x3_jitstressregs0x1000',
297                'gcstress0xc_jitstressregs1',
298                'gcstress0xc_jitstressregs2',
299                'gcstress0xc_jitstressregs3',
300                'gcstress0xc_jitstressregs4',
301                'gcstress0xc_jitstressregs8',
302                'gcstress0xc_jitstressregs0x10',
303                'gcstress0xc_jitstressregs0x80',
304                'gcstress0xc_jitstressregs0x1000'
305     ]
306   
307     def static validLinuxArmScenarios = [
308                'innerloop',
309                'normal',
310                // 'ilrt'
311                'r2r',
312                // 'longgc'
313                // 'formatting'
314                // 'gcsimulator'
315                // 'jitdiff'
316                // 'standalone_gc'
317                // 'gc_reliability_framework'
318                // 'illink'
319                // 'corefx_innerloop'
320                'crossgen_comparison',
321                'pmi_asm_diffs',
322                'r2r_jitstress1',
323                'r2r_jitstress2',
324                'r2r_jitstress1_tiered',
325                'r2r_jitstress2_tiered',
326                'r2r_jitstressregs1',
327                'r2r_jitstressregs2',
328                'r2r_jitstressregs3',
329                'r2r_jitstressregs4',
330                'r2r_jitstressregs8',
331                'r2r_jitstressregs0x10',
332                'r2r_jitstressregs0x80',
333                'r2r_jitstressregs0x1000',
334                'r2r_jitminopts',
335                'r2r_jitforcerelocs',
336                'r2r_gcstress15',
337                'r2r_no_tiered_compilation',
338                'minopts',
339                'tieredcompilation',
340                'no_tiered_compilation',
341                'no_tiered_compilation_innerloop',
342                'forcerelocs',
343                'jitstress1',
344                'jitstress2',
345                'jitstress1_tiered',
346                'jitstress2_tiered',
347                'jitstressregs1',
348                'jitstressregs2',
349                'jitstressregs3',
350                'jitstressregs4',
351                'jitstressregs8',
352                'jitstressregs0x10',
353                'jitstressregs0x80',
354                'jitstressregs0x1000',
355                'jitstress2_jitstressregs1',
356                'jitstress2_jitstressregs2',
357                'jitstress2_jitstressregs3',
358                'jitstress2_jitstressregs4',
359                'jitstress2_jitstressregs8',
360                'jitstress2_jitstressregs0x10',
361                'jitstress2_jitstressregs0x80',
362                'jitstress2_jitstressregs0x1000',
363                'tailcallstress',
364                // 'jitsse2only'                          // Only relevant to xarch
365                // 'jitnosimd'                            // Only interesting on platforms where SIMD support exists.
366                // 'jitincompletehwintrinsic'
367                // 'jitx86hwintrinsicnoavx'
368                // 'jitx86hwintrinsicnoavx2'
369                // 'jitx86hwintrinsicnosimd'
370                // 'jitnox86hwintrinsic'
371                'corefx_baseline',
372                'corefx_minopts',
373                'corefx_tieredcompilation',
374                'corefx_jitstress1',
375                'corefx_jitstress2',
376                'corefx_jitstressregs1',
377                'corefx_jitstressregs2',
378                'corefx_jitstressregs3',
379                'corefx_jitstressregs4',
380                'corefx_jitstressregs8',
381                'corefx_jitstressregs0x10',
382                'corefx_jitstressregs0x80',
383                'corefx_jitstressregs0x1000',
384                'gcstress0x3',
385                'gcstress0xc',
386                'zapdisable',
387                'heapverify1',
388                'gcstress0xc_zapdisable',
389                'gcstress0xc_zapdisable_jitstress2',
390                'gcstress0xc_zapdisable_heapverify1',
391                'gcstress0xc_jitstress1',
392                'gcstress0xc_jitstress2',
393                'gcstress0xc_minopts_heapverify1'
394     ]
395
396     def static validLinuxArm64Scenarios = [
397                'innerloop',
398                'normal',
399                // 'ilrt'
400                'r2r',
401                // 'longgc'
402                // 'formatting'
403                // 'gcsimulator'
404                // 'jitdiff'
405                // 'standalone_gc'
406                // 'gc_reliability_framework'
407                // 'illink'
408                // 'corefx_innerloop'
409                'crossgen_comparison',
410                'pmi_asm_diffs',
411                'r2r_jitstress1',
412                'r2r_jitstress2',
413                'r2r_jitstress1_tiered',
414                'r2r_jitstress2_tiered',
415                'r2r_jitstressregs1',
416                'r2r_jitstressregs2',
417                'r2r_jitstressregs3',
418                'r2r_jitstressregs4',
419                'r2r_jitstressregs8',
420                'r2r_jitstressregs0x10',
421                'r2r_jitstressregs0x80',
422                'r2r_jitstressregs0x1000',
423                'r2r_jitminopts',
424                'r2r_jitforcerelocs',
425                'r2r_gcstress15',
426                'r2r_no_tiered_compilation',
427                'minopts',
428                'tieredcompilation',
429                'no_tiered_compilation',
430                'no_tiered_compilation_innerloop',
431                'forcerelocs',
432                'jitstress1',
433                'jitstress2',
434                'jitstress1_tiered',
435                'jitstress2_tiered',
436                'jitstressregs1',
437                'jitstressregs2',
438                'jitstressregs3',
439                'jitstressregs4',
440                'jitstressregs8',
441                'jitstressregs0x10',
442                'jitstressregs0x80',
443                'jitstressregs0x1000',
444                'jitstress2_jitstressregs1',
445                'jitstress2_jitstressregs2',
446                'jitstress2_jitstressregs3',
447                'jitstress2_jitstressregs4',
448                'jitstress2_jitstressregs8',
449                'jitstress2_jitstressregs0x10',
450                'jitstress2_jitstressregs0x80',
451                'jitstress2_jitstressregs0x1000',
452                'tailcallstress',
453                // 'jitsse2only'                         // Only relevant to xarch
454                'jitnosimd',                             // Only interesting on platforms where SIMD support exists.
455                // 'jitincompletehwintrinsic'
456                // 'jitx86hwintrinsicnoavx'
457                // 'jitx86hwintrinsicnoavx2'
458                // 'jitx86hwintrinsicnosimd'
459                // 'jitnox86hwintrinsic'
460                'corefx_baseline',
461                'corefx_minopts',
462                'corefx_tieredcompilation',
463                'corefx_jitstress1',
464                'corefx_jitstress2',
465                'corefx_jitstressregs1',
466                'corefx_jitstressregs2',
467                'corefx_jitstressregs3',
468                'corefx_jitstressregs4',
469                'corefx_jitstressregs8',
470                'corefx_jitstressregs0x10',
471                'corefx_jitstressregs0x80',
472                'corefx_jitstressregs0x1000',
473                'gcstress0x3',
474                'gcstress0xc',
475                'zapdisable',
476                'heapverify1',
477                'gcstress0xc_zapdisable',
478                'gcstress0xc_zapdisable_jitstress2',
479                'gcstress0xc_zapdisable_heapverify1',
480                'gcstress0xc_jitstress1',
481                'gcstress0xc_jitstress2',
482                'gcstress0xc_minopts_heapverify1'
483     ]
484
485     def static configurationList = ['Debug', 'Checked', 'Release']
486
487     // This is the set of architectures
488     // Some of these are pseudo-architectures:
489     //    armem -- ARM builds/runs using an emulator. Used for Tizen runs.
490     def static architectureList = ['arm', 'armem', 'arm64', 'x64', 'x86']
491
492     // This set of architectures that cross build on Windows and run on Windows ARM64 hardware.
493     def static armWindowsCrossArchitectureList = ['arm', 'arm64']
494 }
495
496 // **************************************************************
497 // Create some specific views
498 // 
499 // These aren't using the Utilities.addStandardFolderView() function, because that creates
500 // views based on a single regular expression. These views will be generated by adding a
501 // specific set of jobs to them.
502 //
503 // Utilities.addStandardFolderView() also creates a lot of additional stuff around the
504 // view, like "Build Statistics", "Job Statistics", "Unstable Jobs". Until it is determined
505 // those are required, don't add them (which simplifies the view pages, as well).
506 // **************************************************************
507
508 class Views {
509     def static MergeJobView = null
510     def static PeriodicJobView = null
511     def static ArchitectureViews = [:]
512     def static OSViews = [:]
513 }
514
515 // MergeJobView: include all jobs that execute when a PR change is merged.
516 Views.MergeJobView = listView('Merge') {
517     recurse()
518     columns {
519         status()
520         weather()
521         name()
522         lastSuccess()
523         lastFailure()
524         lastDuration()
525         buildButton()
526     }
527 }
528
529 // PeriodicJobView: include all jobs that execute on a schedule
530 Views.PeriodicJobView = listView('Periodic') {
531     recurse()
532     columns {
533         status()
534         weather()
535         name()
536         lastSuccess()
537         lastFailure()
538         lastDuration()
539         buildButton()
540     }
541 }
542
543 // Create a view for non-PR jobs for each architecture.
544 Constants.architectureList.each { architecture ->
545     Views.ArchitectureViews[architecture] = listView(architecture) {
546         recurse()
547         columns {
548             status()
549             weather()
550             name()
551             lastSuccess()
552             lastFailure()
553             lastDuration()
554             buildButton()
555         }
556     }
557 }
558
559 // Create a view for non-PR jobs for each OS.
560 Constants.osList.each { os ->
561     // Don't create one for the special 'Windows_NT_BuildOnly'
562     if (os == 'Windows_NT_BuildOnly') {
563         return
564     }
565     Views.OSViews[os] = listView(os) {
566         recurse()
567         columns {
568             status()
569             weather()
570             name()
571             lastSuccess()
572             lastFailure()
573             lastDuration()
574             buildButton()
575         }
576     }
577 }
578
579 def static addToMergeView(def job) {
580     Views.MergeJobView.with {
581         jobs {
582             name(job.name)
583         }
584     }
585 }
586
587 def static addToPeriodicView(def job) {
588     Views.PeriodicJobView.with {
589         jobs {
590             name(job.name)
591         }
592     }
593 }
594
595 def static addToViews(def job, def isFlowJob, def isPR, def architecture, def os, def configuration, def scenario) {
596     if (isPR) {
597         // No views want PR jobs currently.
598         return
599     }
600
601     // We don't want to include in view any job that is only used by a flow job (because we want the views to have only the
602     // "top-level" jobs. Build only jobs are such jobs.
603     if (os == 'Windows_NT_BuildOnly') {
604         return
605     }
606
607     if (!isFlowJob) {
608         // For non-flow jobs, which ones are only used by flow jobs?
609         if ((architecture == 'arm') || (architecture == 'arm64')) {
610             if (isCoreFxScenario(scenario)) {
611                 // We have corefx-specific scenario builds for each of the runs, but these are driven by flow jobs.
612                 return
613             }
614
615             // We're left with the basic normal/innerloop builds. We might want to remove these from the views also, if desired.
616             // However, there are a few, like the Debug Build, that is build only, not "Build and Test", that we should leave.
617         }
618     }
619
620     // Add to architecture view.
621     Views.ArchitectureViews[architecture].with {
622         jobs {
623             name(job.name)
624         }
625     }
626
627     // Add to OS view.
628     Views.OSViews[os].with {
629         jobs {
630             name(job.name)
631         }
632     }
633 }
634
635 def static addPeriodicTriggerHelper(def job, String cronString, boolean alwaysRuns = false) {
636     addToPeriodicView(job)
637     Utilities.addPeriodicTrigger(job, cronString, alwaysRuns)
638 }
639
640 def static addGithubPushTriggerHelper(def job) {
641     // Disable all Push trigger jobs. All jobs will need to be requested.
642     // addToMergeView(job)
643     // Utilities.addGithubPushTrigger(job)
644 }
645
646
647 def static setMachineAffinity(def job, def os, def architecture, def options = null) {
648     assert os instanceof String
649     assert architecture instanceof String
650
651     def armArches = ['arm', 'armem', 'arm64']
652
653     if (!(architecture in armArches)) {
654         assert options == null
655         Utilities.setMachineAffinity(job, os, 'latest-or-auto')
656
657         return
658     }
659
660     // This is an arm(64) job.
661     //
662     // There are several options.
663     //
664     // Windows_NT
665     // 
666     // Arm32 (Build) -> latest-arm64
667     //       |-> os == "Windows_NT" && (architecture == "arm") && options['use_arm64_build_machine'] == true
668     // Arm32 (Test)  -> arm64-windows_nt
669     //       |-> os == "Windows_NT" && (architecture == "arm") && options['use_arm64_build_machine'] == false
670     //
671     // Arm64 (Build) -> latest-arm64
672     //       |-> os == "Windows_NT" && architecture == "arm64" && options['use_arm64_build_machine'] == true
673     // Arm64 (Test)  -> arm64-windows_nt
674     //       |-> os == "Windows_NT" && architecture == "arm64" && options['use_arm64_build_machine'] == false
675     //
676     // Ubuntu
677     //
678     // Arm32 emulator (Build, Test) -> arm-cross-latest
679     //       |-> os == "Tizen" && (architecture == "armem")
680     //
681     // Arm32 hardware (Flow) -> Ubuntu 16.04 latest-or-auto (don't use limited arm hardware)
682     //       |-> os == "Ubuntu" && (architecture == "arm") && options['is_flow_job'] == true
683     // Arm32 hardware (Build) -> Ubuntu 16.04 latest-or-auto
684     //       |-> os == "Ubuntu" && (architecture == "arm") && options['is_build_job'] == true
685     // Arm32 hardware (Test) -> Helix ubuntu.1404.arm32.open queue
686     //       |-> os == "Ubuntu" && (architecture == "arm")
687     //
688     // Arm64 (Build) -> arm64-cross-latest
689     //       |-> os != "Windows_NT" && architecture == "arm64" && options['is_build_job'] == true
690     // Arm64 (Test) -> Helix Ubuntu.1604.Arm64.Iron.Open queue
691     //       |-> os != "Windows_NT" && architecture == "arm64"
692     //
693     // Note: we are no longer using Jenkins tags "arm64-huge-page-size", "arm64-small-page-size".
694     // Support for Linux arm64 large page size has been removed for now, as it wasn't being used.
695     //
696     // Note: we are no longer using Jenkins tag 'latest-arm64' for arm/arm64 Windows build machines. Instead,
697     // we are using public VS2017 arm/arm64 tools in a VM from Helix.
698
699     // This has to be a arm arch
700     assert architecture in armArches
701     if (os == "Windows_NT") {
702         // arm32/arm64 Windows jobs share the same machines for now
703         def isBuild = options['use_arm64_build_machine'] == true
704
705         if (isBuild == true) {
706             job.with {
707                 label('Windows.10.Amd64.ClientRS4.DevEx.Open')
708             }
709         } else {
710             Utilities.setMachineAffinity(job, 'windows.10.arm64.open')
711         }
712     } else {
713         assert os != 'Windows_NT'
714
715         if (architecture == 'armem') {
716             // arm emulator (Tizen). Build and test on same machine,
717             // using Docker.
718             assert os == 'Tizen'
719             Utilities.setMachineAffinity(job, 'Ubuntu', 'arm-cross-latest')
720         }
721         else {
722             // arm/arm64 Ubuntu on hardware.
723             assert architecture == 'arm' || architecture == 'arm64'
724             def isFlow  = (options != null) && (options['is_flow_job'] == true)
725             def isBuild = (options != null) && (options['is_build_job'] == true)
726             if (isFlow || isBuild) {
727                 // arm/arm64 Ubuntu build machine. Build uses docker, so the actual host OS is not
728                 // very important. Therefore, use latest or auto. Flow jobs don't need to use arm hardware.
729                 Utilities.setMachineAffinity(job, 'Ubuntu16.04', 'latest-or-auto')
730             } else {
731                 // arm/arm64 Ubuntu test machine. Specify the Helix queue name here.
732                 if (architecture == 'arm64') {
733                     assert os == 'Ubuntu16.04'
734                     job.with {
735                         label('Ubuntu.1604.Arm64.Iron.Open')
736                     }
737                 }
738                 else {
739                     assert os == 'Ubuntu'
740                     job.with {
741                         label('ubuntu.1404.arm32.open')
742                     }
743                 }
744             }
745         }
746     }
747 }
748
749 // setJobMachineAffinity: compute the machine affinity options for a job,
750 // then set the job with those affinity options.
751 def static setJobMachineAffinity(def architecture, def os, def isBuildJob, def isTestJob, def isFlowJob, def job)
752 {
753     assert (isBuildJob  && !isTestJob && !isFlowJob) ||
754            (!isBuildJob && isTestJob  && !isFlowJob) ||
755            (!isBuildJob && !isTestJob && isFlowJob)
756
757     def affinityOptions = null
758     def affinityArchitecture = architecture
759
760     if (os == "Windows_NT") {
761         if (architecture in Constants.armWindowsCrossArchitectureList) {
762             if (isBuildJob) {
763                 affinityOptions = [ "use_arm64_build_machine" : true ]
764             } else if (isTestJob) {
765                 affinityOptions = [ "use_arm64_build_machine" : false ]
766             } else if (isFlowJob) {
767                 // For the flow jobs set the machine affinity as x64
768                 affinityArchitecture = 'x64'
769             }
770         }
771     }
772     else {
773         if ((architecture == 'arm64') || (architecture == 'arm')) {
774             if (isBuildJob) {
775                 affinityOptions = ['is_build_job': true]
776             } else if (isFlowJob) {
777                 affinityOptions = ['is_flow_job': true]
778             }
779         }
780     }
781
782     setMachineAffinity(job, os, affinityArchitecture, affinityOptions)
783 }
784
785 def static isGCStressRelatedTesting(def scenario) {
786     // The 'r2r_gcstress15' scenario is a basic scenario.
787     // Detect it and make it a GCStress related.
788     if (scenario == 'r2r_gcstress15')
789     {
790         return true;
791     }
792
793     def gcStressTestEnvVars = [ 'COMPlus_GCStress', 'COMPlus_ZapDisable', 'COMPlus_HeapVerify']
794     def scenarioName = scenario.toLowerCase()
795     def isGCStressTesting = false
796     Constants.jitStressModeScenarios[scenario].each{ k, v ->
797         if (k in gcStressTestEnvVars) {
798             isGCStressTesting = true;
799         }
800     }
801     return isGCStressTesting
802 }
803
804 def static isCoreFxScenario(def scenario) {
805     def corefx_prefix = 'corefx_'
806     if (scenario.length() < corefx_prefix.length()) {
807         return false
808     }
809     return scenario.substring(0,corefx_prefix.length()) == corefx_prefix
810 }
811
812 def static isR2RBaselineScenario(def scenario) {
813     return (scenario == 'r2r')
814 }
815
816 def static isR2RStressScenario(def scenario) {
817     return Constants.r2rStressScenarios.containsKey(scenario)
818 }
819
820 def static isR2RScenario(def scenario) {
821     return isR2RBaselineScenario(scenario) || isR2RStressScenario(scenario)
822 }
823
824 def static isJitStressScenario(def scenario) {
825     return Constants.jitStressModeScenarios.containsKey(scenario)
826 }
827
828 def static isLongGc(def scenario) {
829     return (scenario == 'longgc' || scenario == 'gcsimulator')
830 }
831
832 def static isJitDiff(def scenario) {
833     return (scenario == 'jitdiff')
834 }
835
836 def static isGcReliabilityFramework(def scenario) {
837     return (scenario == 'gc_reliability_framework')
838 }
839
840 def static isArmWindowsScenario(def scenario) {
841     return Constants.validArmWindowsScenarios.contains(scenario)
842 }
843
844 def static isValidPrTriggeredInnerLoopJob(os, architecture, configuration, isBuildOnly) {
845     if (isBuildOnly == true) {
846         os = 'Windows_NT_BuildOnly'
847     }
848
849     def validOsPrTriggerArchConfigs = Constants.prTriggeredValidInnerLoopCombos[os]
850     if (validOsPrTriggerArchConfigs != null) {
851         def validOsPrTriggerConfigs = validOsPrTriggerArchConfigs[architecture]
852         if (validOsPrTriggerConfigs != null) {
853             if (configuration in validOsPrTriggerConfigs) {
854                 return true
855             }
856         }
857     }
858
859     return false
860 }
861
862 // This means the job builds and runs the 'innerloop' test set. This does not mean the job is 
863 // scheduled with a default PR trigger despite the correlation being true at the moment.
864 def static isInnerloopTestScenario(def scenario) {
865     return (scenario == 'innerloop' || scenario == 'no_tiered_compilation_innerloop')
866 }
867
868 def static isCrossGenComparisonScenario(def scenario) {
869     return (scenario == 'crossgen_comparison')
870 }
871
872 def static shouldGenerateCrossGenComparisonJob(def os, def architecture, def configuration, def scenario) {
873     assert isCrossGenComparisonScenario(scenario)
874     return ((os == 'Ubuntu' && architecture == 'arm') || (os == 'Ubuntu16.04' && architecture == 'arm64')) && (configuration == 'Checked' || configuration == 'Release')
875 }
876
877 def static getFxBranch(def branch) {
878     def fxBranch = branch
879     // Map 'dev/unix_test_workflow' to 'master' so we can test CoreFX jobs in the CoreCLR dev/unix_test_workflow
880     // branch even though CoreFX doesn't have such a branch.
881     if (branch == 'dev/unix_test_workflow') {
882         fxBranch = 'master'
883     }
884     return fxBranch
885 }
886
887 def static setJobTimeout(newJob, isPR, architecture, configuration, scenario, isBuildOnly) {
888     // 2 hours (120 minutes) is the default timeout
889     def timeout = 120
890
891     if (!isInnerloopTestScenario(scenario)) {
892         // Pri-1 test builds take a long time (see calculateBuildCommands()). So up the Pri-1 build jobs timeout.
893         timeout = 240
894     }
895
896     if (!isBuildOnly) {
897         // Note that these can only increase, never decrease, the Pri-1 timeout possibly set above.
898         if (isGCStressRelatedTesting(scenario)) {
899             timeout = 4320
900         }
901         else if (isCoreFxScenario(scenario)) {
902             timeout = 360
903         }
904         else if (isJitStressScenario(scenario)) {
905             timeout = 300
906         }
907         else if (isR2RBaselineScenario(scenario)) {
908             timeout = 240
909         }
910         else if (isLongGc(scenario)) {
911             timeout = 1440
912         }
913         else if (isJitDiff(scenario)) {
914             timeout = 240
915         }
916         else if (isGcReliabilityFramework(scenario)) {
917             timeout = 1440
918         }
919         else if (architecture == 'armem' || architecture == 'arm64') {
920             timeout = 240
921         }
922
923         if (architecture == 'arm') {
924             // ARM32 machines are particularly slow.
925             timeout += 120
926         }
927     }
928
929     if (configuration == 'Debug') {
930         // Debug runs can be very slow. Add an hour.
931         timeout += 60
932     }
933
934     // If we've changed the timeout from the default, set it in the job.
935
936     if (timeout != 120) {
937         Utilities.setJobTimeout(newJob, timeout)
938     }
939 }
940
941 def static getJobFolder(def scenario) {
942     if (isJitStressScenario(scenario) || isR2RStressScenario(scenario)) {
943         return 'jitstress'
944     }
945     if (scenario == 'illink') {
946         return 'illink'
947     }
948     return ''
949 }
950
951 def static getStressModeDisplayName(def scenario) {
952     def displayStr = ''
953     Constants.jitStressModeScenarios[scenario].each{ k, v ->
954         def prefixLength = 'COMPlus_'.length()
955         if (k.length() >= prefixLength) {
956             def modeName = k.substring(prefixLength, k.length())
957             if (displayStr != '') {
958                 // Separate multiple variables with a space.
959                 displayStr += ' '
960             }
961             displayStr += modeName + '=' + v
962         }
963     }
964
965     if (isCoreFxScenario(scenario)) {
966         displayStr = ('CoreFx ' + displayStr).trim()
967     }
968
969     return displayStr
970 }
971
972 def static getR2RDisplayName(def scenario) {
973     // Assume the scenario name is one from the r2rStressScenarios dict, and remove its "r2r_" prefix.
974     def displayStr = scenario
975     def prefixLength = 'r2r_'.length()
976     if (displayStr.length() >= prefixLength) {
977         displayStr = "R2R " + displayStr.substring(prefixLength, displayStr.length())
978     } else if (scenario == 'r2r') {
979         displayStr = "R2R"
980     }
981     return displayStr
982 }
983
984 def static getScenarioDisplayString(def scenario) {
985     switch (scenario) {
986         case 'innerloop':
987             return "Innerloop Build and Test"
988
989         case 'no_tiered_compilation_innerloop':
990             def displayStr = getStressModeDisplayName(scenario)
991             return "Innerloop Build and Test (Jit - ${displayStr})"
992
993         case 'corefx_innerloop':
994             return "CoreFX Tests"
995
996         case 'normal':
997             return "Build and Test"
998
999         case 'jitdiff':
1000             return "Jit Diff Build and Test"
1001
1002         case 'ilrt':
1003             return "IL RoundTrip Build and Test"
1004
1005         case 'longgc':
1006             return "Long-Running GC Build & Test"
1007
1008         case 'gcsimulator':
1009             return "GC Simulator"
1010
1011         case 'standalone_gc':
1012             return "Standalone GC"
1013
1014         case 'gc_reliability_framework':
1015             return "GC Reliability Framework"
1016
1017         case 'illink':
1018             return "via ILLink"
1019
1020         default:
1021             if (isJitStressScenario(scenario)) {
1022                 def displayStr = getStressModeDisplayName(scenario)
1023                 return "Build and Test (Jit - ${displayStr})"
1024             }
1025             else if (isR2RScenario(scenario)) {
1026                 def displayStr = getR2RDisplayName(scenario)
1027                 return "${displayStr} Build and Test"
1028             }
1029             else {
1030                 return "${scenario}"
1031             }
1032             break
1033     }
1034
1035     println("Unknown scenario: ${scenario}");
1036     assert false
1037 }
1038
1039 //
1040 // Functions to create an environment script.
1041 //      envScriptCreate -- initialize the script (call first)
1042 //      envScriptFinalize -- finalize the script (call last)
1043 //      envScriptSetStressModeVariables -- set stress mode variables in the env script
1044 //      envScriptAppendExistingScript -- append an existing script to the generated script
1045 //
1046 // Each script returns a string of commands. Concatenate all the strings together before
1047 // adding them to the builds commands, to make sure they get executed as one Jenkins script.
1048 //
1049
1050 // Initialize the environment setting script.
1051 def static envScriptCreate(def os, def stepScriptLocation) {
1052     def stepScript = ''
1053     if (os == 'Windows_NT') {
1054         stepScript += "echo Creating TestEnv script\r\n"
1055         stepScript += "if exist ${stepScriptLocation} del ${stepScriptLocation}\r\n"
1056
1057         // Create at least an empty script.
1058         stepScript += "echo. > ${stepScriptLocation}\r\n"
1059     }
1060     else {
1061         stepScript += "echo Creating environment setting script\n"
1062         stepScript += "echo \\#\\!/usr/bin/env bash > ${stepScriptLocation}\n"
1063     }
1064
1065     return stepScript
1066 }
1067
1068 // Generates the string for setting stress mode variables.
1069 def static envScriptSetStressModeVariables(def os, def stressModeVars, def stepScriptLocation) {
1070     def stepScript = ''
1071     if (os == 'Windows_NT') {
1072         stressModeVars.each{ k, v ->
1073             // Write out what we are writing to the script file
1074             stepScript += "echo Setting ${k}=${v}\r\n"
1075             // Write out the set itself to the script file`
1076             stepScript += "echo set ${k}=${v} >> ${stepScriptLocation}\r\n"
1077         }
1078     }
1079     else {
1080         stressModeVars.each{ k, v ->
1081             // Write out what we are writing to the script file
1082             stepScript += "echo Setting ${k}=${v}\n"
1083             // Write out the set itself to the script file`
1084             stepScript += "echo export ${k}=${v} >> ${stepScriptLocation}\n"
1085         }
1086     }
1087
1088     return stepScript
1089 }
1090
1091 // Append an existing script to an environment script.
1092 // Returns string of commands to do this.
1093 def static envScriptAppendExistingScript(def os, def appendScript, def stepScriptLocation) {
1094     assert (os == 'Windows_NT')
1095     def stepScript = ''
1096
1097     stepScript += "echo Appending ${appendScript} to ${stepScriptLocation}\r\n"
1098     stepScript += "type ${appendScript} >> ${stepScriptLocation}\r\n"
1099
1100     return stepScript
1101 }
1102
1103 // Finalize an environment setting script.
1104 // Returns string of commands to do this.
1105 def static envScriptFinalize(def os, def stepScriptLocation) {
1106     def stepScript = ''
1107
1108     if (os == 'Windows_NT') {
1109         // Display the resulting script. This is useful when looking at the output log file.
1110         stepScript += "echo Display the total script ${stepScriptLocation}\r\n"
1111         stepScript += "type ${stepScriptLocation}\r\n"
1112     }
1113     else {
1114         stepScript += "chmod +x ${stepScriptLocation}\n"
1115     }
1116
1117     return stepScript
1118 }
1119
1120 def static isNeedDocker(def architecture, def os, def isBuild) {
1121     if (isBuild) {
1122         if (architecture == 'x86' && os == 'Ubuntu') {
1123             return true
1124         }
1125         else if (architecture == 'armem') {
1126             return true
1127         }
1128         else if (architecture == 'arm') {
1129             if (os == 'Ubuntu') {
1130                 return true
1131             }
1132         }
1133         else if (architecture == 'arm64') {
1134             if (os == 'Ubuntu16.04') {
1135                 return true
1136             }
1137         }
1138     }
1139     else {
1140         if (architecture == 'x86' && os == 'Ubuntu') {
1141             return true
1142         }
1143     }
1144     return false
1145 }
1146
1147 def static getDockerImageName(def architecture, def os, def isBuild) {
1148     // We must change some docker private images to official later
1149     if (isBuild) {
1150         if (architecture == 'x86' && os == 'Ubuntu') {
1151             return "hseok82/dotnet-buildtools-prereqs:ubuntu-16.04-crossx86-ef0ac75-20175511035548"
1152         }
1153         else if (architecture == 'armem') {
1154             if (os == 'Tizen') {
1155                 return "tizendotnet/dotnet-buildtools-prereqs:ubuntu-16.04-cross-e435274-20180426002255-tizen-rootfs-5.0m1"
1156             }
1157         }
1158         else if (architecture == 'arm') {
1159             if (os == 'Ubuntu') {
1160                 return "mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-14.04-cross-e435274-20180426002420"
1161             }
1162         }
1163         else if (architecture == 'arm64') {
1164             if (os == 'Ubuntu16.04') {
1165                 return "mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-a3ae44b-20180315221921"
1166             }
1167         }
1168     }
1169     else {
1170         if (architecture == 'x86' && os == 'Ubuntu') {
1171             return "hseok82/dotnet-buildtools-prereqs:ubuntu1604_x86_test"
1172         }
1173     }
1174     println("Unknown architecture to use docker: ${architecture} ${os}");
1175     assert false
1176 }
1177
1178 def static getTestArtifactsTgzFileName(def osGroup, def architecture, def configuration) {
1179     return "bin-tests-${osGroup}.${architecture}.${configuration}.tgz"
1180 }
1181
1182 // We have a limited amount of some hardware. For these, scale back the periodic testing we do,
1183 // and only allowing using this hardware in some specific branches.
1184 def static jobRequiresLimitedHardware(def architecture, def os) {
1185     if (architecture == 'arm') {
1186         // arm Windows and Linux hardware is limited.
1187         return true
1188     }
1189     else if (architecture == 'arm64') {
1190         // arm64 Windows and Linux hardware is limited.
1191         return true
1192     }
1193     else {
1194         return false
1195     }
1196 }
1197
1198 // Calculates the name of the build job based on some typical parameters.
1199 //
1200 def static getJobName(def configuration, def architecture, def os, def scenario, def isBuildOnly) {
1201     // If the architecture is x64, do not add that info into the build name.
1202     // Need to change around some systems and other builds to pick up the right builds
1203     // to do that.
1204
1205     def suffix = scenario != 'normal' ? "_${scenario}" : '';
1206     if (isBuildOnly) {
1207         suffix += '_bld'
1208     }
1209     def baseName = ''
1210     switch (architecture) {
1211         case 'x64':
1212             if (scenario == 'normal') {
1213                 // For now we leave x64 off of the name for compatibility with other jobs
1214                 baseName = configuration.toLowerCase() + '_' + os.toLowerCase()
1215             }
1216             else if (scenario == 'formatting') {
1217                 // we don't care about the configuration for the formatting job. It runs all configs
1218                 baseName = architecture.toLowerCase() + '_' + os.toLowerCase()
1219             }
1220             else {
1221                 baseName = architecture.toLowerCase() + '_' + configuration.toLowerCase() + '_' + os.toLowerCase()
1222             }
1223             break
1224         case 'armem':
1225             // These are cross builds
1226             assert os == 'Tizen'
1227             baseName = 'armel_cross_' + configuration.toLowerCase() + '_' + os.toLowerCase()
1228             break
1229         case 'arm':
1230         case 'arm64':
1231             // These are cross builds
1232             baseName = architecture.toLowerCase() + '_cross_' + configuration.toLowerCase() + '_' + os.toLowerCase()
1233             break
1234         case 'x86':
1235             baseName = architecture.toLowerCase() + '_' + configuration.toLowerCase() + '_' + os.toLowerCase()
1236             break
1237         default:
1238             println("Unknown architecture: ${architecture}");
1239             assert false
1240             break
1241     }
1242
1243     return baseName + suffix
1244 }
1245
1246 def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def os, def configuration, def scenario, def isFlowJob, def isWindowsBuildOnlyJob, def bidailyCrossList) {
1247
1248     // The dev/unix_test_workflow branch is used for Jenkins CI testing. We generally do not need any non-PR
1249     // triggers in the branch, because that would use machine resources unnecessarily.
1250     if (branch == 'dev/unix_test_workflow') {
1251         return
1252     }
1253
1254     // Limited hardware is restricted for non-PR triggers to certain branches.
1255     if (jobRequiresLimitedHardware(architecture, os) && (!(branch in Constants.LimitedHardwareBranches))) {
1256         return
1257     }
1258
1259     // Ubuntu x86 CI jobs are failing. Disable non-PR triggered jobs to avoid these constant failures
1260     // until this is fixed. Tracked by https://github.com/dotnet/coreclr/issues/19003.
1261     if (architecture == 'x86' && os == 'Ubuntu') {
1262         return
1263     }
1264
1265     def isNormalOrInnerloop = (scenario == "normal" || scenario == "innerloop")
1266
1267     // Check scenario.
1268     switch (scenario) {
1269         case 'crossgen_comparison':
1270             if (isFlowJob && ((os == 'Ubuntu' && architecture == 'arm') || (os == 'Ubuntu16.04' && architecture == 'arm64')) && (configuration == 'Checked' || configuration == 'Release')) {
1271                 addPeriodicTriggerHelper(job, '@daily')
1272             }
1273             break
1274
1275         case 'pmi_asm_diffs':
1276             // No non-PR triggers for now.
1277             break
1278
1279         case 'normal':
1280             switch (architecture) {
1281                 case 'x64':
1282                 case 'x86':
1283                     if (isFlowJob && architecture == 'x86' && os == 'Ubuntu') {
1284                         addPeriodicTriggerHelper(job, '@daily')
1285                     }
1286                     else if (isFlowJob || os == 'Windows_NT' || (architecture == 'x64' && !(os in Constants.crossList))) {
1287                         addGithubPushTriggerHelper(job)
1288                     }
1289                     break
1290                 case 'arm64':
1291                     if (os == 'Windows_NT') {
1292                         if (isFlowJob || (isNormalOrInnerloop && (configuration == 'Debug'))) {
1293                             // We would normally want a per-push trigger, but with limited hardware we can't keep up.
1294                             // Do the builds daily.
1295                             addPeriodicTriggerHelper(job, '@daily')
1296                         }
1297                     }
1298                     else {
1299                         // Only the flow jobs get push triggers; the build and test jobs are triggered by the flow job.
1300                         if (isFlowJob) {
1301                             addPeriodicTriggerHelper(job, '@daily')
1302                         }
1303                     }
1304                     break
1305                 case 'arm':
1306                     if (os == 'Windows_NT') {
1307                         if (isFlowJob || (isNormalOrInnerloop && (configuration == 'Debug'))) {
1308                             // We would normally want a push trigger, but with limited hardware we can't keep up.
1309                             // Do the builds daily.
1310                             addPeriodicTriggerHelper(job, '@daily')
1311                         }
1312                     }
1313                     else {
1314                         assert os == 'Ubuntu'
1315                         // Only the flow jobs get push triggers; the build and test jobs are triggered by the flow job.
1316                         if (isFlowJob) {
1317                             // Currently no push triggers, with limited arm Linux hardware.
1318                             // TODO: If we have enough machine capacity, add some arm Linux push triggers.
1319                             addPeriodicTriggerHelper(job, '@daily')
1320                         }
1321                     }
1322                     break
1323                 case 'armem':
1324                     addGithubPushTriggerHelper(job)
1325                     break
1326                 default:
1327                     println("Unknown architecture: ${architecture}");
1328                     assert false
1329                     break
1330             }
1331             break
1332         case 'r2r':
1333             assert !(os in bidailyCrossList)
1334             // r2r gets a push trigger for checked/release
1335             if (configuration == 'Checked' || configuration == 'Release') {
1336                 if (architecture == 'x64' && os != 'OSX10.12') {
1337                     //Flow jobs should be Windows, Ubuntu, OSX0.12, or CentOS
1338                     if (isFlowJob || os == 'Windows_NT') {
1339                         addGithubPushTriggerHelper(job)
1340                     }
1341                 // OSX10.12 r2r jobs should only run every 12 hours, not daily.
1342                 } else if (architecture == 'x64' && os == 'OSX10.12'){
1343                     if (isFlowJob) {
1344                         addPeriodicTriggerHelper(job, 'H H/12 * * *')
1345                     }
1346                 }
1347                 // For x86, only add per-commit jobs for Windows
1348                 else if (architecture == 'x86') {
1349                     if (os == 'Windows_NT') {
1350                         addGithubPushTriggerHelper(job)
1351                     }
1352                 }
1353                 // arm r2r jobs should only run weekly.
1354                 else if (architecture == 'arm') {
1355                     if (isFlowJob) {
1356                         addPeriodicTriggerHelper(job, '@weekly')
1357                     }
1358                 }
1359                 // arm64 r2r jobs should only run weekly.
1360                 else if (architecture == 'arm64') {
1361                     if (isFlowJob) {
1362                         addPeriodicTriggerHelper(job, '@weekly')
1363                     }
1364                 }
1365             }
1366             break
1367         case 'r2r_jitstress1':
1368         case 'r2r_jitstress2':
1369         case 'r2r_jitstress1_tiered':
1370         case 'r2r_jitstress2_tiered':
1371         case 'r2r_jitstressregs1':
1372         case 'r2r_jitstressregs2':
1373         case 'r2r_jitstressregs3':
1374         case 'r2r_jitstressregs4':
1375         case 'r2r_jitstressregs8':
1376         case 'r2r_jitstressregs0x10':
1377         case 'r2r_jitstressregs0x80':
1378         case 'r2r_jitstressregs0x1000':
1379         case 'r2r_jitminopts':
1380         case 'r2r_jitforcerelocs':
1381         case 'r2r_gcstress15':
1382         case 'r2r_no_tiered_compilation':
1383             assert !(os in bidailyCrossList)
1384
1385             // GCStress=C is currently not supported on OS X
1386             if (os == 'OSX10.12' && isGCStressRelatedTesting(scenario)) {
1387                 break
1388             }
1389
1390             if (configuration == 'Checked' || configuration == 'Release') {
1391                 if (architecture == 'x64') {
1392                     //Flow jobs should be Windows, Ubuntu, OSX10.12, or CentOS
1393                     if (isFlowJob || os == 'Windows_NT') {
1394                         addPeriodicTriggerHelper(job, 'H H * * 3,6') // some time every Wednesday and Saturday
1395                     }
1396                 }
1397                 // For x86, only add periodic jobs for Windows
1398                 else if (architecture == 'x86') {
1399                     if (os == 'Windows_NT') {
1400                         addPeriodicTriggerHelper(job, 'H H * * 3,6') // some time every Wednesday and Saturday
1401                     }
1402                 }
1403                 else if (architecture == 'arm') {
1404                     if (isFlowJob) {
1405                         addPeriodicTriggerHelper(job, '@weekly')
1406                     }
1407                 }
1408                 else if (architecture == 'arm64') {
1409                     if (isFlowJob) {
1410                         addPeriodicTriggerHelper(job, '@weekly')
1411                     }
1412                 }
1413             }
1414             break
1415         case 'longgc':
1416             assert (os == 'Ubuntu' || os == 'Windows_NT' || os == 'OSX10.12')
1417             assert configuration == 'Release'
1418             assert architecture == 'x64'
1419             addPeriodicTriggerHelper(job, '@daily')
1420             // TODO: Add once external email sending is available again
1421             // addEmailPublisher(job, 'dotnetgctests@microsoft.com')
1422             break
1423         case 'gcsimulator':
1424             assert (os == 'Ubuntu' || os == 'Windows_NT' || os == 'OSX10.12')
1425             assert configuration == 'Release'
1426             assert architecture == 'x64'
1427             addPeriodicTriggerHelper(job, 'H H * * 3,6') // some time every Wednesday and Saturday
1428             // TODO: Add once external email sending is available again
1429             // addEmailPublisher(job, 'dotnetgctests@microsoft.com')
1430             break
1431         case 'standalone_gc':
1432             assert (os == 'Ubuntu' || os == 'Windows_NT' || os == 'OSX10.12')
1433             assert (configuration == 'Release' || configuration == 'Checked')
1434             // TODO: Add once external email sending is available again
1435             // addEmailPublisher(job, 'dotnetgctests@microsoft.com')
1436             addPeriodicTriggerHelper(job, '@daily')
1437             break
1438         case 'gc_reliability_framework':
1439             assert (os == 'Ubuntu' || os == 'Windows_NT' || os == 'OSX10.12')
1440             assert (configuration == 'Release' || configuration == 'Checked')
1441             // Only triggered by phrase.
1442             break
1443         case 'ilrt':
1444             assert !(os in bidailyCrossList)
1445             // ILASM/ILDASM roundtrip one gets a daily build, and only for release
1446             if (architecture == 'x64' && configuration == 'Release') {
1447                 if (isFlowJob || os == 'Windows_NT') {
1448                     addPeriodicTriggerHelper(job, '@daily')
1449                 }
1450             }
1451             break
1452         case 'jitdiff':
1453             assert (os == 'Ubuntu' || os == 'Windows_NT' || os == 'OSX10.12')
1454             assert configuration == 'Checked'
1455             assert (architecture == 'x64' || architecture == 'x86')
1456             addGithubPushTriggerHelper(job)
1457             break
1458         case 'formatting':
1459             assert (os == 'Windows_NT' || os == "Ubuntu")
1460             assert architecture == 'x64'
1461             addGithubPushTriggerHelper(job)
1462             break
1463         case 'jitstressregs1':
1464         case 'jitstressregs2':
1465         case 'jitstressregs3':
1466         case 'jitstressregs4':
1467         case 'jitstressregs8':
1468         case 'jitstressregs0x10':
1469         case 'jitstressregs0x80':
1470         case 'jitstressregs0x1000':
1471         case 'minopts':
1472         case 'tieredcompilation':
1473         case 'no_tiered_compilation':
1474         case 'forcerelocs':
1475         case 'jitstress1':
1476         case 'jitstress2':
1477         case 'jitstress1_tiered':
1478         case 'jitstress2_tiered':
1479         case 'jitstress2_jitstressregs1':
1480         case 'jitstress2_jitstressregs2':
1481         case 'jitstress2_jitstressregs3':
1482         case 'jitstress2_jitstressregs4':
1483         case 'jitstress2_jitstressregs8':
1484         case 'jitstress2_jitstressregs0x10':
1485         case 'jitstress2_jitstressregs0x80':
1486         case 'jitstress2_jitstressregs0x1000':
1487         case 'tailcallstress':
1488         case 'jitsse2only':
1489         case 'jitnosimd':
1490         case 'jitnox86hwintrinsic':
1491         case 'jitincompletehwintrinsic':
1492         case 'jitx86hwintrinsicnoavx':
1493         case 'jitx86hwintrinsicnoavx2':
1494         case 'jitx86hwintrinsicnosimd':
1495         case 'corefx_baseline':
1496         case 'corefx_minopts':
1497         case 'corefx_tieredcompilation':
1498         case 'corefx_jitstress1':
1499         case 'corefx_jitstress2':
1500         case 'corefx_jitstressregs1':
1501         case 'corefx_jitstressregs2':
1502         case 'corefx_jitstressregs3':
1503         case 'corefx_jitstressregs4':
1504         case 'corefx_jitstressregs8':
1505         case 'corefx_jitstressregs0x10':
1506         case 'corefx_jitstressregs0x80':
1507         case 'corefx_jitstressregs0x1000':
1508         case 'zapdisable':
1509             if (os == 'CentOS7.1') {
1510                 break
1511             }
1512             if (os in bidailyCrossList) {
1513                 break
1514             }
1515             // ARM corefx testing uses non-flow jobs to provide the configuration-specific
1516             // build for the flow job. We don't need cron jobs for these. Note that the
1517             // Windows ARM jobs depend on a Windows "build only" job that exits the trigger
1518             // function very early, so only non-Windows gets here.
1519             if ((architecture == 'arm') && isCoreFxScenario(scenario) && !isFlowJob) {
1520                 break
1521             }
1522             if ((architecture == 'arm64') && isCoreFxScenario(scenario) && !isFlowJob) {
1523                 break
1524             }
1525             if (jobRequiresLimitedHardware(architecture, os)) {
1526                 if ((architecture == 'arm64') && (os == 'Ubuntu16.04')) {
1527                     // These jobs are very fast on Linux/arm64 hardware, so run them daily.
1528                     addPeriodicTriggerHelper(job, '@daily')
1529                 }
1530                 else {
1531                     addPeriodicTriggerHelper(job, '@weekly')
1532                 }
1533             }
1534             else {
1535                 addPeriodicTriggerHelper(job, '@daily')
1536             }
1537             break
1538         case 'heapverify1':
1539         case 'gcstress0x3':
1540             if (os == 'CentOS7.1') {
1541                 break
1542             }
1543             if (os in bidailyCrossList) {
1544                 break
1545             }
1546             addPeriodicTriggerHelper(job, '@weekly')
1547             break
1548         case 'gcstress0xc':
1549         case 'gcstress0xc_zapdisable':
1550         case 'gcstress0xc_zapdisable_jitstress2':
1551         case 'gcstress0xc_zapdisable_heapverify1':
1552         case 'gcstress0xc_jitstress1':
1553         case 'gcstress0xc_jitstress2':
1554         case 'gcstress0xc_minopts_heapverify1':
1555             if (os == 'OSX10.12') {
1556                 // GCStress=C is currently not supported on OS X
1557                 break
1558             }
1559             if (os == 'CentOS7.1') {
1560                 break
1561             }
1562             if (os in bidailyCrossList) {
1563                 break
1564             }
1565             addPeriodicTriggerHelper(job, '@weekly')
1566             break
1567
1568         case 'illink':
1569             // Testing on other operating systems TBD
1570             assert (os == 'Windows_NT' || os == 'Ubuntu')
1571             if (architecture == 'x64' || architecture == 'x86') {
1572                 if (configuration == 'Checked') {
1573                     addPeriodicTriggerHelper(job, '@daily')
1574                 }
1575             }
1576             break
1577
1578         default:
1579             println("Unknown scenario: ${scenario}");
1580             assert false
1581             break
1582     }
1583     return
1584 }
1585
1586 // **************************
1587 // Define the basic inner loop builds for PR and commit.  This is basically just the set
1588 // of coreclr builds over linux/osx 10.12/windows and debug/release/checked.  In addition, the windows
1589 // builds will do a couple extra steps.
1590 // **************************
1591
1592 // Adds a trigger for the PR build if one is needed.  If isFlowJob is true, then this is the
1593 // flow job that rolls up the build and test for non-windows OS's.  // If the job is a windows build only job,
1594 // it's just used for internal builds
1595 // If you add a job with a trigger phrase, please add that phrase to coreclr/Documentation/project-docs/ci-trigger-phrases.md
1596 def static addTriggers(def job, def branch, def isPR, def architecture, def os, def configuration, def scenario, def isFlowJob, def isWindowsBuildOnlyJob) {
1597     def isNormalOrInnerloop = (scenario == "normal" || scenario == "innerloop")
1598     
1599     if (isWindowsBuildOnlyJob) {
1600         return
1601     }
1602
1603     def bidailyCrossList = ['RHEL7.2', 'Debian8.4']
1604     // Non pull request builds.
1605     if (!isPR) {
1606         addNonPRTriggers(job, branch, isPR, architecture, os, configuration, scenario, isFlowJob, isWindowsBuildOnlyJob, bidailyCrossList)
1607         return
1608     }
1609
1610     def arm64Users = [
1611         'adityamandaleeka',
1612         'AndyAyersMS',
1613         'briansull',
1614         'BruceForstall',
1615         'CarolEidt',
1616         'davidwrighton',
1617         'echesakovMSFT',
1618         'erozenfeld',
1619         'janvorli',
1620         'jashook',
1621         'pgodeq',
1622         'RussKeldorph',
1623         'sandreenko',
1624         'swaroop-sridhar',
1625         'jkotas',
1626         'markwilkie',
1627         'weshaggard',
1628         'tannergooding'
1629     ]
1630
1631     // Pull request builds.  Generally these fall into two categories: default triggers and on-demand triggers
1632     // We generally only have a distinct set of default triggers but a bunch of on-demand ones.
1633
1634     def contextString = ""
1635     def triggerString = ""
1636     def needsTrigger = true
1637     def isDefaultTrigger = false
1638     def isArm64PrivateJob = false
1639     def scenarioString = ""
1640
1641     // Set up default context string and trigger phrases. This is overridden in places, sometimes just to keep
1642     // the existing non-standard descriptions and phrases. In some cases, the scenarios are asymmetric, as for
1643     // some jobs where the Debug configuration just does builds, no tests.
1644     //
1645     // Some configurations, like arm32/arm64, always use the exact scenario name as part of the context string.
1646     // This makes it possible to copy/paste the displayed context string as "@dotnet-bot test <context-string>"
1647     // to invoke the trigger. Any "fancy" context string makes that impossible, requiring the user to either 
1648     // remember the mapping from context string to trigger string, or use "@dotnet-bot help" to look it up.
1649
1650     if (architecture == 'armem') {
1651         assert os == 'Tizen'
1652         architecture = 'armel'
1653     }
1654
1655     switch (architecture) {
1656         case 'armel':
1657         case 'arm':
1658         case 'arm64':
1659             contextString = "${os} ${architecture} Cross ${configuration}"
1660             triggerString = "(?i).*test\\W+${os}\\W+${architecture}\\W+Cross\\W+${configuration}"
1661
1662             if (scenario == 'innerloop') {
1663                 contextString += " Innerloop"
1664                 triggerString += "\\W+Innerloop"
1665             }
1666             else {
1667                 contextString += " ${scenario}"
1668                 triggerString += "\\W+${scenario}"
1669             }
1670
1671             if (scenario == 'pmi_asm_diffs') {
1672                 // Don't add the "Build and Test" part
1673             }
1674             else if (configuration == 'Debug') {
1675                 contextString += " Build"
1676                 triggerString += "\\W+Build"
1677             }
1678             else {
1679                 contextString += " Build and Test"
1680                 triggerString += "\\W+Build and Test"
1681             }
1682
1683             triggerString += ".*"
1684             break
1685
1686         default:
1687             scenarioString = getScenarioDisplayString(scenario)
1688             contextString = "${os} ${architecture} ${configuration} ${scenarioString}"
1689             triggerString = "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}"
1690
1691             switch (scenario) {
1692                 case 'normal':
1693                     triggerString += "\\W+Build and Test.*"
1694                     break
1695
1696                 case 'corefx_innerloop': // maintain this asymmetry
1697                     triggerString += "\\W+CoreFX Tests.*"
1698                     break
1699
1700                 default:
1701                     triggerString += "\\W+${scenario}.*"
1702                     break
1703             }
1704
1705             triggerString += ".*"
1706             break
1707     }
1708
1709     // Now determine what kind of trigger this job needs, if any. Any job should be triggerable, except for
1710     // non-flow jobs that are only used as part of flow jobs.
1711
1712     switch (architecture) {
1713         case 'x64': // editor brace matching: {
1714             if (scenario == 'formatting') {
1715                 assert configuration == 'Checked'
1716                 if (os == 'Windows_NT' || os == 'Ubuntu') {
1717                     isDefaultTrigger = true
1718                     contextString = "${os} ${architecture} Formatting"
1719                 }
1720                 break
1721             }
1722
1723             if (scenario == 'pmi_asm_diffs') {
1724                 // Everything is already set.
1725                 // No default triggers.
1726                 break
1727             }
1728
1729             switch (os) {
1730                 // OpenSUSE, Debian & RedHat get trigger phrases for pri 0 build, and pri 1 build & test
1731                 case 'Debian8.4':
1732                 case 'RHEL7.2':
1733                     if (scenario == 'innerloop') {
1734                         assert !isFlowJob
1735                         contextString = "${os} ${architecture} ${configuration} Innerloop Build"
1736                         isDefaultTrigger = true
1737                         break
1738                     }
1739
1740                     // fall through
1741
1742                 case 'Fedora24':
1743                 case 'Ubuntu16.04':
1744                 case 'Ubuntu16.10':
1745                     assert !isFlowJob
1746                     assert scenario != 'innerloop'
1747                     contextString = "${os} ${architecture} ${configuration} Build"
1748                     triggerString = "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+Build.*"
1749                     break
1750
1751                 case 'Ubuntu':
1752                     if (scenario == 'illink') {
1753                         break
1754                     }
1755                     else if (scenario == 'corefx_innerloop') {
1756                         if (configuration == 'Checked') {
1757                             isDefaultTrigger = true
1758                         }
1759                         break
1760                     }
1761
1762                     // fall through
1763
1764                 case 'OSX10.12':
1765                     // Triggers on the non-flow jobs aren't necessary here
1766                     // Corefx testing uses non-flow jobs.
1767                     if (!isFlowJob && !isCoreFxScenario(scenario)) {
1768                         needsTrigger = false
1769                         break
1770                     }
1771                     switch (scenario) {
1772                         case 'innerloop':
1773                             isDefaultTrigger = true
1774                             break
1775
1776                         case 'no_tiered_compilation_innerloop':
1777                             if (os == 'Ubuntu') {
1778                                 isDefaultTrigger = true
1779                             }
1780                             break
1781
1782                         default:
1783                             break
1784                     }
1785                     break
1786
1787                 case 'CentOS7.1':
1788                     switch (scenario) {
1789                         case 'innerloop':
1790                             // CentOS uses checked for default PR tests while debug is build only
1791                             if (configuration == 'Debug') {
1792                                 isDefaultTrigger = true
1793                                 contextString = "${os} ${architecture} ${configuration} Innerloop Build"
1794                                 break
1795                             }
1796                             
1797                             // Make sure this is a flow job to get build and test.
1798                             if (!isFlowJob) {
1799                                 needsTrigger = false
1800                                 break
1801                             }
1802
1803                             if (configuration == 'Checked') {
1804                                 assert job.name.contains("flow")
1805                                 isDefaultTrigger = true
1806                                 contextString = "${os} ${architecture} ${configuration} Innerloop Build and Test"
1807                             }
1808                             break
1809
1810                         case 'normal':
1811                             // Make sure this is a flow job to get build and test.
1812                             if (!isFlowJob) {
1813                                 needsTrigger = false
1814                                 break
1815                             }
1816                             break
1817
1818                         default:
1819                             break
1820                     }
1821                     break
1822
1823                 case 'Windows_NT':
1824                     switch (scenario) {
1825                         case 'innerloop':
1826                         case 'no_tiered_compilation_innerloop':
1827                             isDefaultTrigger = true
1828                             break
1829
1830                         case 'corefx_innerloop':
1831                             if (configuration == 'Checked' || configuration == 'Release') {
1832                                 isDefaultTrigger = true
1833                             }
1834                             break
1835
1836                         default:
1837                             break
1838                     }
1839                     break
1840
1841                 default:
1842                     println("Unknown os: ${os}");
1843                     assert false
1844                     break
1845
1846             } // switch (os)
1847
1848             break
1849         // editor brace matching: }
1850
1851         case 'armel': // editor brace matching: {
1852             job.with {
1853                 publishers {
1854                     azureVMAgentPostBuildAction {
1855                         agentPostBuildAction('Delete agent if the build was not successful (when idle).')
1856                     }
1857                 }
1858             }
1859
1860             switch (os) {
1861                 case 'Tizen':
1862                     if (scenario == 'innerloop') {
1863                         if (configuration == 'Checked') {
1864                             isDefaultTrigger = true
1865                         }
1866                     }
1867                     break
1868             }
1869
1870             break
1871         // editor brace matching: }
1872
1873         case 'arm':
1874         case 'arm64': // editor brace matching: {
1875
1876             switch (os) {
1877                 case 'Ubuntu':
1878                 case 'Ubuntu16.04':
1879
1880                     // Triggers on the non-flow jobs aren't necessary
1881                     if (!isFlowJob) {
1882                         needsTrigger = false
1883                         break
1884                     }
1885                     if (os == 'Ubuntu' && architecture == 'arm') {
1886                         switch (scenario) {
1887                             case 'innerloop':
1888                             case 'no_tiered_compilation_innerloop':
1889                                 if (configuration == 'Checked') {
1890                                     isDefaultTrigger = true
1891                                 }
1892                                 break
1893                              case 'crossgen_comparison':
1894                                 if (configuration == 'Checked' || configuration == 'Release') {
1895                                     isDefaultTrigger = true
1896                                 }
1897                                 break
1898                         }
1899                     }
1900                     break
1901
1902                 case 'Windows_NT':
1903                     assert isArmWindowsScenario(scenario)
1904
1905                     // For Debug normal/innerloop scenario, we don't do test runs, so we don't use flow jobs. That means we need a trigger for
1906                     // the non-flow Build job. All others need a trigger on the flow job.
1907                     def needsFlowJobTrigger = !(isNormalOrInnerloop && (configuration == 'Debug'))
1908                     if (isFlowJob != needsFlowJobTrigger) {
1909                         needsTrigger = false
1910                         break
1911                     }
1912
1913                     switch (scenario) {
1914                         case 'innerloop':
1915                             if (configuration == 'Checked') {
1916                                 isDefaultTrigger = true
1917                                 isArm64PrivateJob = true
1918                             }
1919                             break
1920                         default:
1921                             isArm64PrivateJob = true
1922                             break
1923                     }
1924                     break
1925                 default:
1926                     println("NYI os: ${os}");
1927                     assert false
1928                     break
1929             }
1930             break
1931
1932         // editor brace matching: }
1933         case 'x86': // editor brace matching: {
1934             assert ((os == 'Windows_NT') || ((os == 'Ubuntu') && isNormalOrInnerloop))
1935             if (os == 'Ubuntu') {
1936                 // Triggers on the non-flow jobs aren't necessary here
1937                 if (!isFlowJob) {
1938                     needsTrigger = false
1939                     break
1940                 }
1941                 
1942                 // on-demand only for ubuntu x86
1943                 contextString = "${os} ${architecture} ${configuration} Build"
1944                 triggerString = "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}.*"
1945                 break
1946             }
1947             switch (scenario) {
1948                 case 'innerloop':
1949                 case 'no_tiered_compilation_innerloop':
1950                     isDefaultTrigger = true
1951                     break
1952                 default:
1953                     break
1954             }
1955             break
1956
1957         // editor brace matching: }
1958
1959         default:
1960             println("Unknown architecture: ${architecture}");
1961             assert false
1962             break
1963     }
1964
1965     if (needsTrigger) {
1966         if (isArm64PrivateJob) {
1967             if (isDefaultTrigger) {
1968                 Utilities.addDefaultPrivateGithubPRTriggerForBranch(job, branch, contextString, null, arm64Users)
1969             }
1970             else {
1971                 Utilities.addPrivateGithubPRTriggerForBranch(job, branch, contextString, triggerString, null, arm64Users)
1972             }
1973         }
1974         else {
1975             if (isDefaultTrigger) {
1976                 Utilities.addGithubPRTriggerForBranch(job, branch, contextString)
1977             }
1978             else {
1979                 Utilities.addGithubPRTriggerForBranch(job, branch, contextString, triggerString)
1980             }
1981         }
1982     }
1983 }
1984
1985 def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR, def architecture, def configuration, def os, def isBuildOnly) {
1986     def buildCommands = []
1987     def osGroup = getOSGroup(os)
1988     def lowerConfiguration = configuration.toLowerCase()
1989
1990     // Which set of tests to build? Innerloop tests build Pri-0.
1991     // Currently, we only generate asm diffs on Pri-0 tests, if we generate asm diffs on tests at all.
1992     // CoreFX testing skipts building tests altogether (done below).
1993     // All other scenarios build Pri-1 tests.
1994     def priority = '1'
1995     if (isInnerloopTestScenario(scenario)) {
1996         priority = '0'
1997     }
1998
1999     def doCoreFxTesting = isCoreFxScenario(scenario)
2000
2001     def buildCoreclrTests = true
2002     if (doCoreFxTesting || (scenario == 'pmi_asm_diffs')) {
2003         // These scenarios don't need the coreclr tests build.
2004         buildCoreclrTests = false
2005     }
2006
2007     // Calculate the build steps, archival, and xunit results
2008     switch (os) {
2009         case 'Windows_NT': // editor brace matching: {
2010             switch (architecture) {
2011                 case 'x64':
2012                 case 'x86':
2013                     def arch = architecture
2014                     def buildOpts = ''
2015
2016                     if (scenario == 'formatting') {
2017                         buildCommands += "python -u tests\\scripts\\format.py -c %WORKSPACE% -o Windows_NT -a ${arch}"
2018                         Utilities.addArchival(newJob, "format.patch", "", true, false)
2019                         break
2020                     }
2021
2022                     if (scenario == 'illink') {
2023                         buildCommands += "tests\\scripts\\build_illink.cmd clone ${arch}"
2024                     }
2025
2026                     // If it is a release build for Windows, ensure PGO is used, else fail the build.
2027                     if ((lowerConfiguration == 'release') &&
2028                         (scenario in Constants.basicScenarios)) {
2029
2030                         buildOpts += ' -enforcepgo'
2031                     }
2032
2033                     if (buildCoreclrTests) {
2034                         buildOpts += " -priority=${priority}"
2035                     } else {
2036                         buildOpts += ' skiptests';
2037                     }
2038
2039                     // Set __TestIntermediateDir to something short. If __TestIntermediateDir is already set, build-test.cmd will
2040                     // output test binaries to that directory. If it is not set, the binaries are sent to a default directory whose name is about
2041                     // 35 characters long.
2042
2043                     buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${arch} ${buildOpts}"
2044
2045                     if (scenario == 'pmi_asm_diffs') {
2046                         // Now, generate the layout. We don't have any tests, but we need to restore the packages before calling runtest.cmd.
2047                         // Call build-test.cmd to do this. It will do a little more than we need, but that's ok.
2048                         buildCommands += "build-test.cmd ${lowerConfiguration} ${arch} skipmanaged skipnative"
2049                         buildCommands += "tests\\runtest.cmd ${lowerConfiguration} ${arch} GenerateLayoutOnly"
2050
2051                         // TODO: Add -target_branch and -commit_hash arguments based on GitHub variables.
2052                         buildCommands += "python -u %WORKSPACE%\\tests\\scripts\\run-pmi-diffs.py -arch ${arch} -ci_arch ${architecture} -build_type ${configuration}"
2053
2054                         // ZIP up the asm
2055                         buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('_\\pmi\\asm', '.\\dasm.${os}.${architecture}.${configuration}.zip')\"";
2056
2057                         // Archive the asm
2058                         Utilities.addArchival(newJob, "dasm.${os}.${architecture}.${configuration}.zip")
2059                         break
2060                     }
2061
2062                     if (!isBuildOnly) {
2063                         def runtestArguments = ''
2064                         def testOpts = 'collectdumps'
2065
2066                         if (isR2RScenario(scenario)) {
2067
2068                             // If this is a ReadyToRun scenario, pass 'crossgen'
2069                             // to cause framework assemblies to be crossgen'ed. Pass 'runcrossgentests'
2070                             // to cause the tests to be crossgen'ed.
2071
2072                             testOpts += ' crossgen runcrossgentests'
2073                         }
2074                         else if (scenario == 'jitdiff') {
2075                             testOpts += ' jitdisasm crossgen'
2076                         }
2077                         else if (scenario == 'ilrt') {
2078                             testOpts += ' ilasmroundtrip'
2079                         }
2080                         else if (isLongGc(scenario)) {
2081                             testOpts += " ${scenario} sequential"
2082                         }
2083                         else if (scenario == 'standalone_gc') {
2084                             testOpts += ' gcname clrgc.dll'
2085                         }
2086                         else if (scenario == 'illink') {
2087                             testOpts += " link %WORKSPACE%\\linker\\linker\\bin\\netcore_Release\\netcoreapp2.0\\win10-${arch}\\publish\\illink.exe"
2088                         }
2089
2090                         // Default per-test timeout is 10 minutes. For stress modes and Debug scenarios, increase this
2091                         // to 30 minutes (30 * 60 * 1000 = 180000). The "timeout" argument to runtest.cmd sets this, by
2092                         // taking a timeout value in milliseconds. (Note that it sets the __TestTimeout environment variable,
2093                         // which is read by the xunit harness.)
2094                         if (isJitStressScenario(scenario) || isR2RStressScenario(scenario) || (lowerConfiguration == 'debug'))
2095                         {
2096                             def timeout = 1800000
2097                             testOpts += " timeout ${timeout}"
2098                         }
2099
2100                         // If we are running a stress mode, we should write out the set of key
2101                         // value env pairs to a file at this point and then we'll pass that to runtest.cmd
2102
2103                         def envScriptPath = ''
2104                         if (isJitStressScenario(scenario) || isR2RStressScenario(scenario)) {
2105                             def buildCommandsStr = ''
2106                             envScriptPath = "%WORKSPACE%\\SetStressModes.bat"
2107                             buildCommandsStr += envScriptCreate(os, envScriptPath)
2108
2109                             if (isJitStressScenario(scenario)) {
2110                                 buildCommandsStr += envScriptSetStressModeVariables(os, Constants.jitStressModeScenarios[scenario], envScriptPath)
2111                             }
2112                             else if (isR2RStressScenario(scenario)) {
2113                                 buildCommandsStr += envScriptSetStressModeVariables(os, Constants.r2rStressScenarios[scenario], envScriptPath)
2114                             }
2115
2116                             envScriptFinalize(os, envScriptPath)
2117
2118                             // Note that buildCommands is an array of individually executed commands; we want all the commands used to 
2119                             // create the SetStressModes.bat script to be executed together, hence we accumulate them as strings
2120                             // into a single script.
2121                             buildCommands += buildCommandsStr
2122                         }
2123                         if (envScriptPath != '') {
2124                             testOpts += " TestEnv ${envScriptPath}"
2125                         }
2126
2127                         runtestArguments = "${lowerConfiguration} ${arch} ${testOpts}"
2128
2129                         if (doCoreFxTesting) {
2130                             if (scenario == 'corefx_innerloop') {
2131                                 // Create CORE_ROOT and testhost
2132                                 buildCommands += "build-test.cmd ${lowerConfiguration} ${arch} buildtesthostonly"                                
2133                                 buildCommands += "tests\\runtest.cmd ${runtestArguments} CoreFXTestsAll"
2134
2135                                 // Archive and process (only) the test results
2136                                 Utilities.addArchival(newJob, "bin/Logs/**/testResults.xml", "", /* doNotFailIfNothingArchived */ true, /* archiveOnlyIfSuccessful */ false)
2137                                 Utilities.addXUnitDotNETResults(newJob, "bin/Logs/**/testResults.xml")
2138                             }
2139                             else {
2140                                 def workspaceRelativeFxRoot = "_/fx"
2141                                 def absoluteFxRoot = "%WORKSPACE%\\_\\fx"
2142                                 def fxBranch = getFxBranch(branch)
2143
2144                                 buildCommands += "python -u %WORKSPACE%\\tests\\scripts\\run-corefx-tests.py -arch ${arch} -ci_arch ${architecture} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${fxBranch} -env_script ${envScriptPath}"
2145
2146                                 // Archive and process (only) the test results
2147                                 Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/artifacts/bin/**/testResults.xml", "", /* doNotFailIfNothingArchived */ true, /* archiveOnlyIfSuccessful */ false)
2148                                 Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/artifacts/bin/**/testResults.xml")
2149
2150                                 //Archive additional build stuff to diagnose why my attempt at fault injection isn't causing CI to fail
2151                                 Utilities.addArchival(newJob, "SetStressModes.bat", "", true, false)
2152                                 Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/artifacts/bin/testhost/**", "", true, false)
2153                             }
2154                         }
2155                         else if (isGcReliabilityFramework(scenario)) {
2156                             buildCommands += "tests\\runtest.cmd ${runtestArguments} GenerateLayoutOnly"
2157                             buildCommands += "tests\\scripts\\run-gc-reliability-framework.cmd ${arch} ${configuration}"
2158                         }
2159                         else {
2160                             def buildCommandsStr = "call tests\\runtest.cmd ${runtestArguments}\r\n"
2161                             if (!isBuildOnly) {
2162                                 // If we ran the tests, collect the test logs collected by xunit. We want to do this even if the tests fail, so we
2163                                 // must do it in the same batch file as the test run.
2164
2165                                 buildCommandsStr += "echo on\r\n" // Show the following commands in the log. "echo" doesn't alter the errorlevel.
2166                                 buildCommandsStr += "set saved_errorlevel=%errorlevel%\r\n"
2167                                 buildCommandsStr += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${arch}.${configuration}\\Reports', '.\\bin\\tests\\testReports.zip')\"\r\n";
2168                                 buildCommandsStr += "exit /b %saved_errorlevel%\r\n"
2169
2170                                 def doNotFailIfNothingArchived = true
2171                                 def archiveOnlyIfSuccessful = false
2172                                 Utilities.addArchival(newJob, "bin/tests/testReports.zip", "", doNotFailIfNothingArchived, archiveOnlyIfSuccessful)
2173                             }
2174                             buildCommands += buildCommandsStr
2175                         }
2176                     } // end if (!isBuildOnly)
2177
2178                     if (!doCoreFxTesting) {
2179                         // Run the rest of the build
2180                         // Build the mscorlib for the other OS's
2181                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} linuxmscorlib"
2182                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} osxmscorlib"
2183                        
2184                         if (arch == 'x64') {
2185                             buildCommands += "build.cmd ${lowerConfiguration} arm64 linuxmscorlib"
2186                         }
2187
2188                         if (!isJitStressScenario(scenario)) {
2189                             // Zip up the tests directory so that we don't use so much space/time copying
2190                             // 10s of thousands of files around.
2191                             buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${arch}.${configuration}', '.\\bin\\tests\\tests.zip')\"";
2192
2193                             // For Windows, pull full test results and test drops for x86/x64.
2194                             // No need to pull for stress mode scenarios (downstream builds use the default scenario)
2195                             Utilities.addArchival(newJob, "bin/Product/**,bin/tests/tests.zip", "bin/Product/**/.nuget/**")
2196                         }
2197
2198                         if (scenario == 'jitdiff') {
2199                             // retrieve jit-dasm output for base commit, and run jit-diff
2200                             if (!isBuildOnly) {
2201                                 // if this is a build only job, we want to keep the default (build) artifacts for the flow job
2202                                 Utilities.addArchival(newJob, "bin/tests/${osGroup}.${arch}.${configuration}/dasm/**")
2203                             }
2204                         }
2205
2206                         if (!isBuildOnly) {
2207                             Utilities.addXUnitDotNETResults(newJob, 'bin/**/TestRun*.xml', true)
2208                         }
2209                     }
2210
2211                     // Archive the logs, even if the build failed (which is when they are most interesting).
2212                     Utilities.addArchival(newJob, "bin/Logs/*.log,bin/Logs/*.wrn,bin/Logs/*.err,bin/Logs/MsbuildDebugLogs/*", "", /* doNotFailIfNothingArchived */ true, /* archiveOnlyIfSuccessful */ false)
2213                     break
2214                 case 'arm':
2215                 case 'arm64':
2216                     assert isArmWindowsScenario(scenario)
2217
2218                     def buildOpts = ''
2219
2220                     if (buildCoreclrTests) {
2221                         buildOpts += " -priority=${priority}"
2222                     } else {
2223                         buildOpts += ' skiptests'
2224                     }
2225
2226                     // This is now a build only job. Do not run tests. Use the flow job.
2227                     buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} ${buildOpts}"
2228
2229                     if (doCoreFxTesting) {
2230                         assert isBuildOnly
2231
2232                         // Set the stress mode variables; this is incorporated into the generated CoreFx RunTests.cmd files.
2233                         def envScriptPath = ''
2234                         def buildCommandsStr = ''
2235                         envScriptPath = "%WORKSPACE%\\SetStressModes.bat"
2236                         buildCommandsStr += envScriptCreate(os, envScriptPath)
2237                         buildCommandsStr += envScriptSetStressModeVariables(os, Constants.jitStressModeScenarios[scenario], envScriptPath)
2238                         envScriptFinalize(os, envScriptPath)
2239                         buildCommands += buildCommandsStr
2240
2241                         def workspaceRelativeFxRootLinux = "_/fx"
2242                         def workspaceRelativeFxRootWin = "_\\fx"
2243                         def absoluteFxRoot = "%WORKSPACE%\\_\\fx"
2244                         def fxBranch = getFxBranch(branch)
2245
2246                         buildCommands += "python -u %WORKSPACE%\\tests\\scripts\\run-corefx-tests.py -arch ${architecture} -ci_arch ${architecture} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${fxBranch} -env_script ${envScriptPath} -no_run_tests"
2247
2248                         // Zip up the CoreFx runtime and tests. We don't need the CoreCLR binaries; they have been copied to the CoreFX tree.
2249                         buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('${workspaceRelativeFxRootWin}\\artifacts\\bin\\testhost\\netcoreapp-Windows_NT-Release-${architecture}', '${workspaceRelativeFxRootWin}\\fxruntime.zip')\"";
2250                         buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('${workspaceRelativeFxRootWin}\\artifacts\\bin\\tests', '${workspaceRelativeFxRootWin}\\fxtests.zip')\"";
2251
2252                         Utilities.addArchival(newJob, "${workspaceRelativeFxRootLinux}/fxruntime.zip")
2253                         Utilities.addArchival(newJob, "${workspaceRelativeFxRootLinux}/fxtests.zip")
2254                     } else {
2255                         // Zip up the tests directory so that we don't use so much space/time copying
2256                         // 10s of thousands of files around.
2257                         buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${architecture}.${configuration}', '.\\bin\\tests\\tests.zip')\"";
2258
2259                         // Add archival.
2260                         Utilities.addArchival(newJob, "bin/Product/**,bin/tests/tests.zip", "bin/Product/**/.nuget/**")
2261                     }
2262
2263                     // Archive the logs, even if the build failed (which is when they are most interesting).
2264                     Utilities.addArchival(newJob, "bin/Logs/*.log,bin/Logs/*.wrn,bin/Logs/*.err,bin/Logs/MsbuildDebugLogs/*", "", /* doNotFailIfNothingArchived */ true, /* archiveOnlyIfSuccessful */ false)
2265                     break
2266                 default:
2267                     println("Unknown architecture: ${architecture}");
2268                     assert false
2269                     break
2270             }
2271             break
2272         // end case 'Windows_NT'; editor brace matching: }
2273         case 'Ubuntu':
2274         case 'Ubuntu16.04':
2275         case 'Ubuntu16.10':
2276         case 'Debian8.4':
2277         case 'OSX10.12':
2278         case 'CentOS7.1':
2279         case 'RHEL7.2':
2280         case 'Tizen':
2281         case 'Fedora24': // editor brace matching: {
2282             switch (architecture) {
2283                 case 'x86':
2284                     if (os == 'Ubuntu') {
2285                         // build and PAL test
2286                         def dockerImage = getDockerImageName(architecture, os, true)
2287                         buildCommands += "docker run -i --rm -v \${WORKSPACE}:/opt/code -w /opt/code -e ROOTFS_DIR=/crossrootfs/x86 ${dockerImage} ./build.sh ${architecture} cross ${lowerConfiguration}"
2288                         dockerImage = getDockerImageName(architecture, os, false)
2289                         buildCommands += "docker run -i --rm -v \${WORKSPACE}:/opt/code -w /opt/code ${dockerImage} ./src/pal/tests/palsuite/runpaltests.sh /opt/code/bin/obj/${osGroup}.${architecture}.${configuration} /opt/code/bin/paltestout"
2290                         Utilities.addArchival(newJob, "bin/Product/**,bin/obj/*/tests/**/*.so", "bin/Product/**/.nuget/**")
2291                         Utilities.addXUnitDotNETResults(newJob, '**/pal_tests.xml')
2292                     }
2293                     break
2294
2295                 case 'x64':
2296                     if (scenario == 'formatting') {
2297                         buildCommands += "python tests/scripts/format.py -c \${WORKSPACE} -o Linux -a ${architecture}"
2298                         Utilities.addArchival(newJob, "format.patch", "", true, false)
2299                         break
2300                     }
2301
2302                     if (scenario == 'pmi_asm_diffs') {
2303                         buildCommands += "./build.sh ${lowerConfiguration} ${architecture} skiptests skipbuildpackages"
2304                         buildCommands += "./build-test.sh ${lowerConfiguration} ${architecture} generatelayoutonly"
2305
2306                         // TODO: Add -target_branch and -commit_hash arguments based on GitHub variables.
2307                         buildCommands += "python -u \${WORKSPACE}/tests/scripts/run-pmi-diffs.py -arch ${architecture} -ci_arch ${architecture} -build_type ${configuration}"
2308
2309                         // Archive the asm
2310                         buildCommands += "tar -czf dasm.${os}.${architecture}.${configuration}.tgz ./_/pmi/asm"
2311                         Utilities.addArchival(newJob, "dasm.${os}.${architecture}.${configuration}.tgz")
2312                         break
2313                     }
2314
2315                     if (scenario == 'illink') {
2316                         assert(os == 'Ubuntu')
2317                         buildCommands += "./tests/scripts/build_illink.sh --clone --arch=${architecture}"
2318                     }
2319
2320                     if (!doCoreFxTesting) {
2321                         // We run pal tests on all OS but generate mscorlib (and thus, nuget packages)
2322                         // only on supported OS platforms.
2323                         def bootstrapRid = Utilities.getBoostrapPublishRid(os)
2324                         def bootstrapRidEnv = bootstrapRid != null ? "__PUBLISH_RID=${bootstrapRid} " : ''
2325
2326                         buildCommands += "${bootstrapRidEnv}./build.sh ${lowerConfiguration} ${architecture}"
2327
2328                         def testBuildOpts = ""
2329                         if (priority == '1') {
2330                             testBuildOpts = "priority1"
2331                         }
2332
2333                         buildCommands += "./build-test.sh ${lowerConfiguration} ${architecture} ${testBuildOpts}"
2334                         buildCommands += "src/pal/tests/palsuite/runpaltests.sh \${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration} \${WORKSPACE}/bin/paltestout"
2335
2336                         // Archive the bin/tests folder for *_tst jobs
2337                         def testArtifactsTgzFileName = getTestArtifactsTgzFileName(osGroup, architecture, configuration)
2338                         buildCommands += "tar -czf ${testArtifactsTgzFileName} bin/tests/${osGroup}.${architecture}.${configuration}"
2339                         Utilities.addArchival(newJob, "${testArtifactsTgzFileName}", "")
2340                         // And pal tests
2341                         Utilities.addXUnitDotNETResults(newJob, '**/pal_tests.xml')
2342                     }
2343                     else {
2344                         if (scenario == 'corefx_innerloop') {
2345                             assert os == 'Ubuntu' || 'OSX10.12'
2346                             assert architecture == 'x64'
2347
2348                             buildCommands += "./build.sh ${lowerConfiguration} ${architecture} skiptests"
2349                             buildCommands += "./build-test.sh ${lowerConfiguration} ${architecture} generatetesthostonly"
2350                             buildCommands += "./tests/runtest.sh ${lowerConfiguration} --corefxtestsall --testHostDir=\${WORKSPACE}/bin/tests/${osGroup}.${architecture}.${configuration}/testhost/ --coreclr-src=\${WORKSPACE}"
2351
2352                             // Archive and process (only) the test results
2353                             Utilities.addArchival(newJob, "bin/Logs/**/testResults.xml", "", /* doNotFailIfNothingArchived */ true, /* archiveOnlyIfSuccessful */ false)
2354                             Utilities.addXUnitDotNETResults(newJob, "bin/Logs/**/testResults.xml")
2355                         }
2356                         else {
2357                             // Corefx stress testing
2358                             assert os == 'Ubuntu'
2359                             assert architecture == 'x64'
2360                             assert lowerConfiguration == 'checked'
2361                             assert isJitStressScenario(scenario)
2362
2363                             // Build coreclr
2364                             buildCommands += "./build.sh ${lowerConfiguration} ${architecture}"
2365
2366                             def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
2367
2368                             def envScriptCmds = envScriptCreate(os, scriptFileName)
2369                             envScriptCmds += envScriptSetStressModeVariables(os, Constants.jitStressModeScenarios[scenario], scriptFileName)
2370                             envScriptCmds += envScriptFinalize(os, scriptFileName)
2371                             buildCommands += envScriptCmds
2372
2373                             // Build and text corefx
2374                             def workspaceRelativeFxRoot = "_/fx"
2375                             def absoluteFxRoot = "\$WORKSPACE/${workspaceRelativeFxRoot}"
2376                             def fxBranch = getFxBranch(branch)
2377
2378                             buildCommands += "python -u \$WORKSPACE/tests/scripts/run-corefx-tests.py -arch ${architecture} -ci_arch ${architecture} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${fxBranch} -env_script ${scriptFileName}"
2379
2380                             // Archive and process (only) the test results
2381                             Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/artifacts/bin/**/testResults.xml", "", /* doNotFailIfNothingArchived */ true, /* archiveOnlyIfSuccessful */ false)
2382                             Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/artifacts/bin/**/testResults.xml")
2383                         }
2384                     }
2385
2386                     // Archive the logs, even if the build failed (which is when they are most interesting).
2387                     Utilities.addArchival(newJob, "bin/Logs/*.log,bin/Logs/*.wrn,bin/Logs/*.err,bin/Logs/MsbuildDebugLogs/*", "", /* doNotFailIfNothingArchived */ true, /* archiveOnlyIfSuccessful */ false)
2388                     break
2389                 case 'armem':
2390                     // Emulator cross builds for ARM runs on Tizen currently
2391                     assert os == 'Tizen'
2392
2393                     def arm_abi = "armel"
2394                     def linuxCodeName = "tizen"
2395
2396                     // Unzip the Windows test binaries first. Exit with 0
2397                     buildCommands += "unzip -q -o ./bin/tests/tests.zip -d ./bin/tests/Windows_NT.x64.${configuration} || exit 0"
2398
2399                     // Unpack the corefx binaries
2400                     buildCommands += "mkdir ./bin/CoreFxBinDir"
2401                     buildCommands += "tar -xf ./artifacts/bin/build.tar.gz -C ./bin/CoreFxBinDir"
2402
2403                     // Call the ARM CI script to cross build and test using docker
2404                     buildCommands += """./tests/scripts/arm32_ci_script.sh \\
2405                     --mode=docker \\
2406                     --${arm_abi} \\
2407                     --linuxCodeName=${linuxCodeName} \\
2408                     --buildConfig=${lowerConfiguration} \\
2409                     --testRootDir=./bin/tests/Windows_NT.x64.${configuration} \\
2410                     --coreFxBinDir=./bin/CoreFxBinDir \\
2411                     --testDirFile=./tests/testsRunningInsideARM.txt"""
2412
2413                     // Basic archiving of the build, no pal tests
2414                     Utilities.addArchival(newJob, "bin/Product/**,bin/obj/*/tests/**/*.dylib,bin/obj/*/tests/**/*.so", "bin/Product/**/.nuget/**")
2415                     break
2416                 case 'arm64':
2417                 case 'arm':
2418                     // Non-Windows ARM cross builds on hardware run on Ubuntu only
2419                     assert (os == 'Ubuntu') || (os == 'Ubuntu16.04')
2420
2421                     // Add some useful information to the log file. Ignore return codes.
2422                     buildCommands += "uname -a || true"
2423
2424                     // Cross build the Ubuntu/arm product using docker with a docker image that contains the correct
2425                     // Ubuntu cross-compilation toolset (running on a Ubuntu x64 host).
2426                     // For CoreFX testing, we only need the product build; we don't need to generate the layouts. The product
2427                     // build is then copied into the corefx layout by the run-corefx-test.py script. For CoreFX testing, we
2428                     // ZIP up the generated CoreFX runtime and tests.
2429
2430                     def dockerImage = getDockerImageName(architecture, os, true)
2431                     def dockerCmd = "docker run -i --rm -v \${WORKSPACE}:\${WORKSPACE} -w \${WORKSPACE} -e ROOTFS_DIR=/crossrootfs/${architecture} ${dockerImage} "
2432
2433                     buildCommands += "${dockerCmd}\${WORKSPACE}/build.sh ${lowerConfiguration} ${architecture} cross"
2434
2435                     if (doCoreFxTesting) {
2436                         def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
2437
2438                         def envScriptCmds = envScriptCreate(os, scriptFileName)
2439                         envScriptCmds += envScriptSetStressModeVariables(os, Constants.jitStressModeScenarios[scenario], scriptFileName)
2440                         envScriptCmds += envScriptFinalize(os, scriptFileName)
2441                         buildCommands += envScriptCmds
2442
2443                         // Build and text corefx
2444                         def workspaceRelativeFxRootLinux = "_/fx"
2445                         def absoluteFxRoot = "\$WORKSPACE/${workspaceRelativeFxRootLinux}"
2446                         def fxBranch = getFxBranch(branch)
2447
2448                         buildCommands += "${dockerCmd}python -u \$WORKSPACE/tests/scripts/run-corefx-tests.py -arch ${architecture} -ci_arch ${architecture} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${fxBranch} -env_script ${scriptFileName} -no_run_tests"
2449
2450                         // Docker creates files with root permission, so we need to zip in docker also, or else we'll get permission errors.
2451                         buildCommands += "${dockerCmd}zip -r ${workspaceRelativeFxRootLinux}/fxruntime.zip ${workspaceRelativeFxRootLinux}/artifacts/bin/testhost/netcoreapp-Linux-Release-${architecture}"
2452                         buildCommands += "${dockerCmd}zip -r ${workspaceRelativeFxRootLinux}/fxtests.zip ${workspaceRelativeFxRootLinux}/artifacts/bin/tests"
2453
2454                         Utilities.addArchival(newJob, "${workspaceRelativeFxRootLinux}/fxruntime.zip")
2455                         Utilities.addArchival(newJob, "${workspaceRelativeFxRootLinux}/fxtests.zip")
2456                     }
2457                     else if (isCrossGenComparisonScenario(scenario)) {
2458                         buildCommands += "${dockerCmd}\${WORKSPACE}/build-test.sh ${lowerConfiguration} ${architecture} cross generatelayoutonly"
2459
2460                         def workspaceRelativeProductBinDir = "bin/Product/${osGroup}.${architecture}.${configuration}"
2461                         def workspaceRelativeCoreLib = "${workspaceRelativeProductBinDir}/IL/System.Private.CoreLib.dll"
2462                         def workspaceRelativeCoreRootDir = "bin/tests/${osGroup}.${architecture}.${configuration}/Tests/Core_Root"
2463                         def workspaceRelativeCrossGenComparisonScript = "tests/scripts/crossgen_comparison.py"
2464                         def workspaceRelativeResultsDir = "_"
2465                         def workspaceRelativeArtifactsArchive = "${os}.${architecture}.${configuration}.${scenario}.zip"
2466                         def crossGenComparisonCmd = "python -u \${WORKSPACE}/${workspaceRelativeCrossGenComparisonScript} "
2467                         def crossArch = "x64"
2468                         def crossGenExecutable = "\${WORKSPACE}/${workspaceRelativeProductBinDir}/${crossArch}/crossgen"
2469                         def workspaceRelativeCrossArchResultDir = "${workspaceRelativeResultsDir}/${osGroup}.${crossArch}_${architecture}.${configuration}"
2470
2471                         buildCommands += "${dockerCmd}mkdir -p \${WORKSPACE}/${workspaceRelativeCrossArchResultDir}"
2472                         buildCommands += "${dockerCmd}${crossGenComparisonCmd}crossgen_corelib --crossgen ${crossGenExecutable} --il_corelib \${WORKSPACE}/${workspaceRelativeCoreLib} --result_dir \${WORKSPACE}/${workspaceRelativeCrossArchResultDir}"
2473                         buildCommands += "${dockerCmd}${crossGenComparisonCmd}crossgen_framework --crossgen ${crossGenExecutable} --core_root \${WORKSPACE}/${workspaceRelativeCoreRootDir} --result_dir \${WORKSPACE}/${workspaceRelativeCrossArchResultDir}"
2474
2475                         buildCommands += "${dockerCmd}zip -r ${workspaceRelativeArtifactsArchive} ${workspaceRelativeCoreLib} ${workspaceRelativeCoreRootDir} ${workspaceRelativeCrossGenComparisonScript} ${workspaceRelativeResultsDir}"
2476                         Utilities.addArchival(newJob, "${workspaceRelativeArtifactsArchive}")
2477                     }
2478                     else if (scenario == 'pmi_asm_diffs') {
2479                         buildCommands += "${dockerCmd}\${WORKSPACE}/build-test.sh ${lowerConfiguration} ${architecture} cross generatelayoutonly"
2480
2481                         // Pass `--skip_diffs` -- the actual diffs will be done on an arm machine in the test job. This is the build job.
2482                         // TODO: Add -target_branch and -commit_hash arguments based on GitHub variables.
2483                         buildCommands += "python -u \${WORKSPACE}/tests/scripts/run-pmi-diffs.py -arch ${architecture} -ci_arch ${architecture} -build_type ${configuration} --skip_diffs"
2484
2485                         // Archive what we created.
2486                         buildCommands += "tar -czf product.${os}.${architecture}.${lowerConfiguration}.tgz ./bin/Product/Linux.${architecture}.${configuration}"
2487                         buildCommands += "tar -czf product.baseline.${os}.${architecture}.${lowerConfiguration}.tgz ./_/pmi/base/bin/Product/Linux.${architecture}.${configuration}"
2488                         buildCommands += "tar -czf coreroot.${os}.${architecture}.${lowerConfiguration}.tgz ./bin/tests/Linux.${architecture}.${configuration}/Tests/Core_Root"
2489                         buildCommands += "tar -czf coreroot.baseline.${os}.${architecture}.${lowerConfiguration}.tgz ./_/pmi/base/bin/tests/Linux.${architecture}.${configuration}/Tests/Core_Root"
2490
2491                         // Archive the built artifacts
2492                         Utilities.addArchival(newJob, "product.${os}.${architecture}.${lowerConfiguration}.tgz,product.baseline.${os}.${architecture}.${lowerConfiguration}.tgz,coreroot.${os}.${architecture}.${lowerConfiguration}.tgz,coreroot.baseline.${os}.${architecture}.${lowerConfiguration}.tgz")
2493                     }
2494                     else {
2495                         // Then, using the same docker image, build the tests and generate the CORE_ROOT layout.
2496
2497                         def testBuildOpts = ""
2498                         if (priority == '1') {
2499                             testBuildOpts = "priority1"
2500                         }
2501
2502                         buildCommands += "${dockerCmd}\${WORKSPACE}/build-test.sh ${lowerConfiguration} ${architecture} cross ${testBuildOpts}"
2503
2504                         // ZIP up the built tests (including CORE_ROOT and native test components copied to the CORE_ROOT) for the test job (created in the flow job code)
2505                         def testArtifactsTgzFileName = getTestArtifactsTgzFileName(osGroup, architecture, configuration)
2506                         buildCommands += "tar -czf ${testArtifactsTgzFileName} bin/tests/${osGroup}.${architecture}.${configuration}"
2507
2508                         Utilities.addArchival(newJob, "${testArtifactsTgzFileName}", "")
2509                     }
2510
2511                     // Archive the logs, even if the build failed (which is when they are most interesting).
2512                     Utilities.addArchival(newJob, "bin/Logs/*.log,bin/Logs/*.wrn,bin/Logs/*.err,bin/Logs/MsbuildDebugLogs/*", "", /* doNotFailIfNothingArchived */ true, /* archiveOnlyIfSuccessful */ false)
2513
2514                     // We need to clean up the build machines; the docker build leaves newly built files with root permission, which
2515                     // the cleanup task in Jenkins can't remove.
2516                     newJob.with {
2517                         publishers {
2518                             azureVMAgentPostBuildAction {
2519                                 agentPostBuildAction('Delete agent after build execution (when idle).')
2520                             }
2521                         }
2522                     }
2523                     break
2524                 default:
2525                     println("Unknown architecture: ${architecture}");
2526                     assert false
2527                     break
2528             }
2529             break
2530         // editor brace matching: }
2531         default:
2532             println("Unknown os: ${os}");
2533             assert false
2534             break
2535     } // os
2536
2537     return buildCommands
2538 }
2539
2540 // Determine if we should generate a job for the given parameters. This is for non-flow jobs: either build and test, or build only.
2541 // Returns true if the job should be generated.
2542 def static shouldGenerateJob(def scenario, def isPR, def architecture, def configuration, def os, def isBuildOnly)
2543 {
2544     def windowsArmJob = ((os == "Windows_NT") && (architecture in Constants.armWindowsCrossArchitectureList))
2545
2546     // Innerloop jobs (except corefx_innerloop) are no longer created in Jenkins
2547     // The only exception is windows arm(64)
2548     if (isInnerloopTestScenario(scenario) && isPR && !windowsArmJob) {
2549         assert scenario != 'corefx_innerloop'
2550         return false;
2551     }
2552
2553     if (!isPR) {
2554         if (isInnerloopTestScenario(scenario)) {
2555             return false
2556         }
2557
2558         if (scenario == 'corefx_innerloop') {
2559             return false
2560         }
2561     }
2562
2563     // Tizen is only supported for armem architecture
2564     if (os == 'Tizen' && architecture != 'armem') {
2565         return false
2566     }
2567
2568     // Filter based on architecture.
2569
2570     switch (architecture) {
2571         case 'arm':
2572             if ((os != 'Windows_NT') && (os != 'Ubuntu')) {
2573                 return false
2574             }
2575             break
2576         case 'arm64':
2577             if ((os != 'Windows_NT') && (os != 'Ubuntu16.04')) {
2578                 return false
2579             }
2580             break
2581         case 'armem':
2582             if (os != 'Tizen') {
2583                 return false
2584             }
2585             break
2586         case 'x86':
2587             if ((os != 'Windows_NT') && (os != 'Ubuntu')) {
2588                 return false
2589             }
2590             break
2591         case 'x64':
2592             // Everything implemented
2593             break
2594         default:
2595             println("Unknown architecture: ${architecture}")
2596             assert false
2597             break
2598     }
2599
2600     // Which (Windows) build only jobs are required?
2601
2602     def isNormalOrInnerloop = (scenario == 'innerloop' || scenario == 'normal')
2603
2604     if (isBuildOnly) {
2605         switch (architecture) {
2606             case 'arm':
2607             case 'arm64':
2608                 // We use build only jobs for Windows arm/arm64 cross-compilation corefx testing, so we need to generate builds for that.
2609                 if (!isCoreFxScenario(scenario)) {
2610                     return false
2611                 }
2612                 break
2613             case 'x64':
2614             case 'x86':
2615                 if (!isNormalOrInnerloop) {
2616                     return false
2617                 }
2618                 break
2619             default:
2620                 return false
2621         }
2622     }
2623
2624     // Filter based on scenario.
2625
2626     if (isJitStressScenario(scenario)) {
2627         if (configuration != 'Checked') {
2628             return false
2629         }
2630
2631         def isEnabledOS = (os == 'Windows_NT') ||
2632                           (os == 'Ubuntu' && (architecture == 'x64') && isCoreFxScenario(scenario)) ||
2633                           (os == 'Ubuntu' && architecture == 'arm') ||
2634                           (os == 'Ubuntu16.04' && architecture == 'arm64')
2635         if (!isEnabledOS) {
2636             return false
2637         }
2638
2639         switch (architecture) {
2640             case 'x64':
2641                 break
2642
2643             case 'x86':
2644                 // x86 ubuntu: no stress modes
2645                 if (os == 'Ubuntu') {
2646                     return false
2647                 }
2648                 break
2649
2650             case 'arm':
2651             case 'arm64':
2652                 // We use build only jobs for Windows arm/arm64 cross-compilation corefx testing, so we need to generate builds for that.
2653                 // No "regular" Windows arm corefx jobs, e.g.
2654                 // For Ubuntu arm corefx testing, we use regular jobs (not "build only" since only Windows has "build only", and
2655                 // the Ubuntu arm "regular" jobs don't run tests anyway).
2656                 if (os == 'Windows_NT') {
2657                     if (! (isBuildOnly && isCoreFxScenario(scenario)) ) {
2658                         return false
2659                     }
2660                 }
2661                 else {
2662                     if (!isCoreFxScenario(scenario)) {
2663                         return false
2664                     }
2665                 }
2666                 break
2667
2668             default:
2669                 // armem: no stress jobs for ARM emulator.
2670                 return false
2671         }
2672     }
2673     else if (isR2RScenario(scenario)) {
2674         if (os != 'Windows_NT') {
2675             return false
2676         }
2677
2678         if (isR2RBaselineScenario(scenario)) {
2679             // no need for Debug scenario; Checked is sufficient
2680             if (configuration != 'Checked' && configuration != 'Release') {
2681                 return false
2682             }
2683         }
2684         else if (isR2RStressScenario(scenario)) {
2685             // Stress scenarios only run with Checked builds, not Release (they would work with Debug, but be slow).
2686             if (configuration != 'Checked') {
2687                 return false
2688             }
2689         }
2690
2691         switch (architecture) {
2692             case 'arm':
2693             case 'arm64':
2694                 // Windows arm/arm64 ready-to-run jobs use flow jobs and test jobs, but depend on "normal" (not R2R specific) build jobs.
2695                 return false
2696
2697             default:
2698                 break
2699         }
2700     }
2701     else if (isCrossGenComparisonScenario(scenario)) {
2702         return shouldGenerateCrossGenComparisonJob(os, architecture, configuration, scenario)
2703     }
2704     else {
2705         // Skip scenarios
2706         switch (scenario) {
2707             case 'ilrt':
2708                 // The ilrt build isn't necessary except for Windows_NT2003.  Non-Windows NT uses
2709                 // the default scenario build
2710                 if (os != 'Windows_NT') {
2711                     return false
2712                 }
2713                 // Only x64 for now
2714                 if (architecture != 'x64') {
2715                     return false
2716                 }
2717                 // Release only
2718                 if (configuration != 'Release') {
2719                     return false
2720                 }
2721                 break
2722             case 'jitdiff':
2723                 if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX10.12') {
2724                     return false
2725                 }
2726                 if (architecture != 'x64') {
2727                     return false
2728                 }
2729                 if (configuration != 'Checked') {
2730                     return false
2731                 }
2732                 break
2733             case 'longgc':
2734             case 'gcsimulator':
2735                 if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX10.12') {
2736                     return false
2737                 }
2738                 if (architecture != 'x64') {
2739                     return false
2740                 }
2741                 if (configuration != 'Release') {
2742                     return false
2743                 }
2744                 break
2745             case 'gc_reliability_framework':
2746             case 'standalone_gc':
2747                 if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX10.12') {
2748                     return false
2749                 }
2750
2751                 if (architecture != 'x64') {
2752                     return false
2753                 }
2754
2755                 if (configuration != 'Release' && configuration != 'Checked') {
2756                     return false
2757                 }
2758                 break
2759             // We only run Windows and Ubuntu x64 Checked for formatting right now
2760             case 'formatting':
2761                 if (os != 'Windows_NT' && os != 'Ubuntu') {
2762                     return false
2763                 }
2764                 if (architecture != 'x64') {
2765                     return false
2766                 }
2767                 if (configuration != 'Checked') {
2768                     return false
2769                 }
2770                 break
2771             case 'illink':
2772                 if (os != 'Windows_NT' && (os != 'Ubuntu' || architecture != 'x64')) {
2773                     return false
2774                 }
2775                 if (architecture != 'x64' && architecture != 'x86') {
2776                     return false
2777                 }
2778                 break
2779             case 'normal':
2780                 // Nothing skipped
2781                 break
2782             case 'innerloop':
2783                 if (!isValidPrTriggeredInnerLoopJob(os, architecture, configuration, isBuildOnly)) {
2784                     return false
2785                 }
2786                 break
2787             case 'corefx_innerloop':
2788                 if (os != 'Windows_NT' && os != 'Ubuntu' &&  os != 'OSX10.12') {
2789                     return false
2790                 }
2791                 if (architecture != 'x64') {
2792                     return false
2793                 }
2794                 break
2795             case 'pmi_asm_diffs':
2796                 if (configuration != 'Checked') {
2797                     return false
2798                 }
2799                 if (architecture == 'armem') {
2800                     return false
2801                 }
2802                 // Currently, we don't support pmi_asm_diffs for Windows arm/arm64. We don't have a dotnet CLI available to
2803                 // build jitutils. The jobs are not in validArmWindowsScenarios.
2804                 if ((os == 'Windows_NT') && (architecture == 'arm' || architecture == 'arm64')) {
2805                     return false
2806                 }
2807                 // Currently, no support for Linux x86.
2808                 if ((os != 'Windows_NT') && (architecture == 'x86')) {
2809                     return false
2810                 }
2811                 break
2812             default:
2813                 println("Unknown scenario: ${scenario}")
2814                 assert false
2815                 break
2816         }
2817     }
2818
2819     // The job was not filtered out, so we should generate it!
2820     return true
2821 }
2822
2823 Constants.allScenarios.each { scenario ->
2824     [true, false].each { isPR ->
2825         Constants.architectureList.each { architecture ->
2826             Constants.configurationList.each { configuration ->
2827                 Constants.osList.each { os ->
2828                     // If the OS is Windows_NT_BuildOnly, set the isBuildOnly flag to true
2829                     // and reset the os to Windows_NT
2830                     def isBuildOnly = false
2831                     if (os == 'Windows_NT_BuildOnly') {
2832                         isBuildOnly = true
2833                         os = 'Windows_NT'
2834                     }
2835
2836                     if (!shouldGenerateJob(scenario, isPR, architecture, configuration, os, isBuildOnly)) {
2837                         return
2838                     }
2839
2840                     // Calculate names
2841                     def jobName = getJobName(configuration, architecture, os, scenario, isBuildOnly)
2842                     def folderName = getJobFolder(scenario)
2843
2844                     // Create the new job
2845                     def newJob = job(Utilities.getFullJobName(project, jobName, isPR, folderName)) {}
2846
2847                     addToViews(newJob, false, isPR, architecture, os, configuration, scenario) // isFlowJob == false
2848
2849                     setJobMachineAffinity(architecture, os, true, false, false, newJob) // isBuildJob = true, isTestJob = false, isFlowJob = false
2850
2851                     Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
2852                     addTriggers(newJob, branch, isPR, architecture, os, configuration, scenario, false, isBuildOnly) // isFlowJob==false
2853                     setJobTimeout(newJob, isPR, architecture, configuration, scenario, isBuildOnly)
2854
2855                     // Copy Windows build test binaries and corefx build artifacts for Linux cross build for armem.
2856                     // We don't use a flow job for this, but we do depend on there being existing builds with these
2857                     // artifacts produced.
2858                     if ((architecture == 'armem') && (os == 'Tizen')) {
2859                         // Define the Windows Tests and Corefx build job names
2860                         def lowerConfiguration = configuration.toLowerCase()
2861                         def WindowsTestsName = projectFolder + '/' +
2862                                                Utilities.getFullJobName(project,
2863                                                                         getJobName(lowerConfiguration, 'x64' , 'windows_nt', 'normal', true),
2864                                                                         false)
2865                         def fxBranch = getFxBranch(branch)
2866                         def corefxFolder = Utilities.getFolderName('dotnet/corefx') + '/' +
2867                                            Utilities.getFolderName(fxBranch)
2868
2869                         def arm_abi = 'armel'
2870                         def corefx_os = 'tizen'
2871
2872                         // Let's use release CoreFX to test checked CoreCLR,
2873                         // because we do not generate checked CoreFX in CoreFX CI yet.
2874                         def corefx_lowerConfiguration = lowerConfiguration
2875                         if (lowerConfiguration == 'checked') {
2876                             corefx_lowerConfiguration = 'release'
2877                         }
2878
2879                         // Copy the Windows test binaries and the Corefx build binaries
2880                         newJob.with {
2881                             steps {
2882                                 copyArtifacts(WindowsTestsName) {
2883                                     includePatterns('bin/tests/tests.zip')
2884                                     buildSelector {
2885                                         latestSuccessful(true)
2886                                     }
2887                                 }
2888                                 copyArtifacts("${corefxFolder}/${corefx_os}_${arm_abi}_cross_${corefx_lowerConfiguration}") {
2889                                     includePatterns('artifacts/bin/build.tar.gz')
2890                                     buildSelector {
2891                                         latestSuccessful(true)
2892                                     }
2893                                 }
2894                             } // steps
2895                         } // newJob.with
2896                     }
2897
2898                     def buildCommands = calculateBuildCommands(newJob, scenario, branch, isPR, architecture, configuration, os, isBuildOnly)
2899
2900                     newJob.with {
2901                         steps {
2902                             if (os == 'Windows_NT') {
2903                                 buildCommands.each { buildCommand ->
2904                                     batchFile(buildCommand)
2905                                 }
2906                             }
2907                             else {
2908                                 buildCommands.each { buildCommand ->
2909                                     shell(buildCommand)
2910                                 }
2911                             }
2912                         } // steps
2913                     } // newJob.with
2914
2915                 } // os
2916             } // configuration
2917         } // architecture
2918     } // isPR
2919 } // scenario
2920
2921 // Create a Windows ARM/ARM64 test job that will be used by a flow job.
2922 // Returns the newly created job.
2923 def static CreateWindowsArmTestJob(def dslFactory, def project, def architecture, def os, def configuration, def scenario, def isPR, def inputCoreCLRBuildName)
2924 {
2925     def osGroup = getOSGroup(os)
2926     def jobName = getJobName(configuration, architecture, os, scenario, false) + "_tst"
2927
2928     def jobFolder = getJobFolder(scenario)
2929     def newJob = dslFactory.job(Utilities.getFullJobName(project, jobName, isPR, jobFolder)) {
2930         parameters {
2931             stringParam('CORECLR_BUILD', '', "Build number to copy CoreCLR ${osGroup} binaries from")
2932         }
2933
2934         steps {
2935             // Set up the copies
2936
2937             // Coreclr build we are trying to test
2938             //
2939             //  ** NOTE ** This will, correctly, overwrite the CORE_ROOT from the Windows test archive
2940
2941             copyArtifacts(inputCoreCLRBuildName) {
2942                 excludePatterns('**/testResults.xml', '**/*.ni.dll')
2943                 buildSelector {
2944                     buildNumber('${CORECLR_BUILD}')
2945                 }
2946             }
2947
2948             if (isCoreFxScenario(scenario)) {
2949
2950                 // Only arm/arm64 supported for corefx testing now.
2951                 assert architecture == 'arm' || architecture == 'arm64'
2952
2953                 // Unzip CoreFx runtime
2954                 batchFile("powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('_\\fx\\fxruntime.zip', '_\\fx\\artifacts\\bin\\testhost\\netcoreapp-Windows_NT-Release-${architecture}')\"")
2955
2956                 // Unzip CoreFx tests.
2957                 batchFile("powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('_\\fx\\fxtests.zip', '_\\fx\\artifacts\\bin\\tests')\"")
2958
2959                 // Add the script to run the corefx tests
2960                 def corefx_runtime_path   = "%WORKSPACE%\\_\\fx\\artifacts\\bin\\testhost\\netcoreapp-Windows_NT-Release-${architecture}"
2961                 def corefx_tests_dir      = "%WORKSPACE%\\_\\fx\\artifacts\\bin\\tests"
2962                 def corefx_exclusion_file = "%WORKSPACE%\\tests\\${architecture}\\corefx_test_exclusions.txt"
2963                 batchFile("call %WORKSPACE%\\tests\\scripts\\run-corefx-tests.bat ${corefx_runtime_path} ${corefx_tests_dir} ${corefx_exclusion_file} ${architecture}")
2964
2965             } else { // !isCoreFxScenario(scenario)
2966
2967                 // Unzip tests.
2968                 batchFile("powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('bin\\tests\\tests.zip', 'bin\\tests\\${osGroup}.${architecture}.${configuration}')\"")
2969
2970                 def buildCommands = ""
2971
2972                 def coreRootLocation = "%WORKSPACE%\\bin\\tests\\Windows_NT.${architecture}.${configuration}\\Tests\\Core_Root"
2973                 def addEnvVariable =  { variable, value -> buildCommands += "set ${variable}=${value}\r\n"}
2974                 def addCommand = { cmd -> buildCommands += "${cmd}\r\n"}
2975
2976                 // Make sure Command Extensions are enabled. Used so %ERRORLEVEL% is available.
2977                 addCommand("SETLOCAL ENABLEEXTENSIONS")
2978
2979                 // For all jobs 
2980                 addEnvVariable("CORE_ROOT", coreRootLocation)
2981                 addEnvVariable("COMPlus_NoGuiOnAssert", "1")
2982                 addEnvVariable("COMPlus_ContinueOnAssert", "0")
2983
2984                 // If we are running a stress mode, we'll set those variables as well
2985                 if (isJitStressScenario(scenario) || isR2RStressScenario(scenario)) {
2986                     def stressValues = null
2987                     if (isJitStressScenario(scenario)) {
2988                         stressValues = Constants.jitStressModeScenarios[scenario]
2989                     }
2990                     else {
2991                         stressValues = Constants.r2rStressScenarios[scenario]
2992                     }
2993
2994                     stressValues.each { key, value -> 
2995                         addEnvVariable(key, value)
2996                     }
2997                 }
2998
2999                 if (isR2RScenario(scenario)) {
3000                     // Crossgen the framework assemblies.
3001                     buildCommands += """
3002 @for %%F in (%CORE_ROOT%\\*.dll) do @call :PrecompileAssembly "%CORE_ROOT%" "%%F" %%~nxF
3003 @goto skip_PrecompileAssembly
3004
3005 :PrecompileAssembly
3006 @REM Skip mscorlib since it is already precompiled.
3007 @if /I "%3" == "mscorlib.dll" exit /b 0
3008 @if /I "%3" == "mscorlib.ni.dll" exit /b 0
3009
3010 "%CORE_ROOT%\\crossgen.exe" /Platform_Assemblies_Paths "%CORE_ROOT%" %2 >nul 2>nul
3011 @if "%errorlevel%" == "-2146230517" (
3012     echo %2 is not a managed assembly.
3013 ) else if "%errorlevel%" == "-2146234344" (
3014     echo %2 is not a managed assembly.
3015 ) else if %errorlevel% neq 0 (
3016     echo Unable to precompile %2
3017 ) else (
3018     echo Precompiled %2
3019 )
3020 @exit /b 0
3021
3022 :skip_PrecompileAssembly
3023 """
3024
3025                     // Set RunCrossGen variable to cause test wrappers to invoke their logic to run
3026                     // crossgen on tests before running them.
3027                     addEnvVariable("RunCrossGen", "true")
3028                 } // isR2RScenario(scenario)
3029
3030                 // Run runtest.cmd
3031                 // Do not run generate layout. It will delete the correct CORE_ROOT, and we do not have a correct product
3032                 // dir to copy from.
3033                 def runtestCommand = "call %WORKSPACE%\\tests\\runtest.cmd ${architecture} ${configuration} skipgeneratelayout"
3034
3035                 addCommand("${runtestCommand}")
3036                 addCommand("echo on") // Show the following commands in the log. "echo" doesn't alter the errorlevel.
3037                 addCommand("set saved_errorlevel=%errorlevel%")
3038
3039                 // Collect the test logs collected by xunit. Ignore errors here. We want to collect these even if the run
3040                 // failed for some reason, so it needs to be in this batch file.
3041
3042                 addCommand("powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${architecture}.${configuration}\\Reports', '.\\bin\\tests\\testReports.zip')\"");
3043
3044                 // Use the runtest.cmd errorlevel as the script errorlevel.
3045                 addCommand("exit /b %saved_errorlevel%")
3046
3047                 batchFile(buildCommands)
3048             } // non-corefx testing
3049         } // steps
3050     } // job
3051
3052     if (!isCoreFxScenario(scenario)) {
3053         def doNotFailIfNothingArchived = true
3054         def archiveOnlyIfSuccessful = false
3055         Utilities.addArchival(newJob, "bin/tests/testReports.zip", "", doNotFailIfNothingArchived, archiveOnlyIfSuccessful)
3056
3057         Utilities.addXUnitDotNETResults(newJob, 'bin/**/TestRun*.xml', true)
3058     }
3059
3060     return newJob
3061 }
3062
3063 // Create a test job not covered by the "Windows ARM" case that will be used by a flow job.
3064 // E.g., non-Windows tests.
3065 // Returns the newly created job.
3066 def static CreateOtherTestJob(def dslFactory, def project, def branch, def architecture, def os, def configuration, def scenario, def isPR, def inputCoreCLRBuildName)
3067 {
3068     def lowerConfiguration = configuration.toLowerCase()
3069
3070     def isUbuntuArm64Job = ((os == "Ubuntu16.04") && (architecture == 'arm64'))
3071     def isUbuntuArm32Job = ((os == "Ubuntu") && (architecture == 'arm'))
3072     def isUbuntuArmJob = isUbuntuArm32Job || isUbuntuArm64Job
3073
3074     def doCoreFxTesting = isCoreFxScenario(scenario)
3075     def isPmiAsmDiffsScenario = (scenario == 'pmi_asm_diffs')
3076
3077     def workspaceRelativeFxRootLinux = "_/fx" // only used for CoreFX testing
3078
3079     def osGroup = getOSGroup(os)
3080     def jobName = getJobName(configuration, architecture, os, scenario, false) + "_tst"
3081
3082     def testOpts = ''
3083     def useServerGC = false
3084
3085     // Enable Server GC for Ubuntu PR builds
3086     // REVIEW: why? Does this apply to all architectures? Why only PR?
3087     if (os == 'Ubuntu' && isPR) {
3088         testOpts += ' --useServerGC'
3089         useServerGC = true
3090     }
3091
3092     if (isR2RScenario(scenario)) {
3093
3094         testOpts += ' --crossgen --runcrossgentests'
3095
3096         if (scenario == 'r2r_jitstress1') {
3097             testOpts += ' --jitstress=1'
3098         }
3099         else if (scenario == 'r2r_jitstress2') {
3100             testOpts += ' --jitstress=2'
3101         }
3102         else if (scenario == 'r2r_jitstress1_tiered') {
3103             testOpts += ' --jitstress=1'
3104         }
3105         else if (scenario == 'r2r_jitstress2_tiered') {
3106             testOpts += ' --jitstress=2'
3107         }
3108         else if (scenario == 'r2r_jitstressregs1') {
3109             testOpts += ' --jitstressregs=1'
3110         }
3111         else if (scenario == 'r2r_jitstressregs2') {
3112             testOpts += ' --jitstressregs=2'
3113         }
3114         else if (scenario == 'r2r_jitstressregs3') {
3115             testOpts += ' --jitstressregs=3'
3116         }
3117         else if (scenario == 'r2r_jitstressregs4') {
3118             testOpts += ' --jitstressregs=4'
3119         }
3120         else if (scenario == 'r2r_jitstressregs8') {
3121             testOpts += ' --jitstressregs=8'
3122         }
3123         else if (scenario == 'r2r_jitstressregs0x10') {
3124             testOpts += ' --jitstressregs=0x10'
3125         }
3126         else if (scenario == 'r2r_jitstressregs0x80') {
3127             testOpts += ' --jitstressregs=0x80'
3128         }
3129         else if (scenario == 'r2r_jitstressregs0x1000') {
3130             testOpts += ' --jitstressregs=0x1000'
3131         }
3132         else if (scenario == 'r2r_jitminopts') {
3133             testOpts += ' --jitminopts'
3134         }
3135         else if (scenario == 'r2r_jitforcerelocs') {
3136             testOpts += ' --jitforcerelocs'
3137         }
3138         else if (scenario == 'r2r_gcstress15') {
3139             testOpts += ' --gcstresslevel=0xF'
3140         }
3141     }
3142     else if (scenario == 'jitdiff') {
3143         testOpts += ' --jitdisasm --crossgen'
3144     }
3145     else if (scenario == 'illink') {
3146         testOpts += ' --link=\$WORKSPACE/linker/linker/bin/netcore_Release/netcoreapp2.0/ubuntu-x64/publish/illink'
3147     }
3148     else if (isLongGc(scenario)) {
3149         // Long GC tests behave very poorly when they are not
3150         // the only test running (many of them allocate until OOM).
3151         testOpts += ' --sequential'
3152
3153         // A note - runtest.sh does have "--long-gc" and "--gcsimulator" options
3154         // for running long GC and GCSimulator tests, respectively. We don't use them
3155         // here because using a playlist file produces much more readable output on the CI machines
3156         // and reduces running time.
3157         //
3158         // The Long GC playlist contains all of the tests that are
3159         // going to be run. The GCSimulator playlist contains all of
3160         // the GC simulator tests.
3161         if (scenario == 'longgc') {
3162             testOpts += ' --long-gc --playlist=./tests/longRunningGcTests.txt'
3163         }
3164         else if (scenario == 'gcsimulator') {
3165             testOpts += ' --gcsimulator --playlist=./tests/gcSimulatorTests.txt'
3166         }
3167     }
3168     else if (isGcReliabilityFramework(scenario)) {
3169         testOpts += ' --build-overlay-only'
3170     }
3171     else if (scenario == 'standalone_gc') {
3172         if (osGroup == 'OSX') {
3173             testOpts += ' --gcname=libclrgc.dylib'
3174         }
3175         else if (osGroup == 'Linux') {
3176             testOpts += ' --gcname=libclrgc.so'
3177         }
3178         else {
3179             println("Unexpected OS group: ${osGroup} for os ${os}")
3180             assert false
3181         }
3182     }
3183
3184     def jobFolder = getJobFolder(scenario)
3185     def newJob = dslFactory.job(Utilities.getFullJobName(project, jobName, isPR, jobFolder)) {
3186         parameters {
3187             stringParam('CORECLR_BUILD', '', "Build number to copy CoreCLR ${osGroup} binaries from")
3188         }
3189
3190         steps {
3191             // Set up the copies
3192
3193             // Coreclr build we are trying to test
3194             //
3195             // HACK: the Ubuntu arm64 copyArtifacts Jenkins plug-in is ridiculously slow (45 minutes to
3196             // 1.5 hours for this step). Instead, directly use wget, which is fast (1 minute).
3197
3198             if (!isUbuntuArm64Job) {
3199                 copyArtifacts(inputCoreCLRBuildName) {
3200                     excludePatterns('**/testResults.xml', '**/*.ni.dll')
3201                     buildSelector {
3202                         buildNumber('${CORECLR_BUILD}')
3203                     }
3204                 }
3205             }
3206
3207             if (isUbuntuArmJob) {
3208                 // Add some useful information to the log file. Ignore return codes.
3209                 shell("uname -a || true")
3210             }
3211
3212             if (isUbuntuArm64Job) {
3213                 // Copy the required artifacts directly, using wget, e.g.:
3214                 // 
3215                 //  https://ci.dot.net/job/dotnet_coreclr/job/master/job/arm64_cross_checked_ubuntu16.04_innerloop_prtest/16/artifact/testnativebin.checked.zip
3216                 //  https://ci.dot.net/job/dotnet_coreclr/job/master/job/arm64_cross_checked_ubuntu16.04_innerloop_prtest/16/artifact/tests.checked.zip
3217                 // 
3218                 // parameterized as:
3219                 //
3220                 //  https://ci.dot.net/job/${mungedProjectName}/job/${mungedBranchName}/job/${inputJobName}/${CORECLR_BUILD}/artifact/testnativebin.checked.zip
3221                 //  https://ci.dot.net/job/${mungedProjectName}/job/${mungedBranchName}/job/${inputJobName}/${CORECLR_BUILD}/artifact/tests.checked.zip
3222                 //
3223                 // CoreFX example artifact URLs:
3224                 //
3225                 //  https://ci.dot.net/job/dotnet_coreclr/job/dev_unix_test_workflow/job/jitstress/job/arm64_cross_checked_ubuntu16.04_corefx_baseline_prtest/1/artifact/_/fx/fxruntime.zip
3226                 //  https://ci.dot.net/job/dotnet_coreclr/job/dev_unix_test_workflow/job/jitstress/job/arm64_cross_checked_ubuntu16.04_corefx_baseline_prtest/1/artifact/_/fx/fxtests.zip
3227                 //
3228                 // Note that the source might be in a "jitstress" folder.
3229                 //
3230                 // Use `--progress=dot:giga` to display some progress output, but limit it in the log file.
3231                 //
3232                 // Use `--directory-prefix=_/fx` to specify where to put the corefx files (to match what other platforms do). Use this instead of `-O`.
3233
3234                 shell("echo \"Using wget instead of the Jenkins copy artifacts plug-in to copy artifacts from ${inputCoreCLRBuildName}\"")
3235
3236                 def mungedProjectName = Utilities.getFolderName(project)
3237                 def mungedBranchName = Utilities.getFolderName(branch)
3238
3239                 def doCrossGenComparison = isCrossGenComparisonScenario(scenario)
3240                 def inputCoreCLRBuildScenario = isInnerloopTestScenario(scenario) ? 'innerloop' : 'normal'
3241                 if (isPmiAsmDiffsScenario || doCoreFxTesting || doCrossGenComparison) {
3242                     // These depend on unique builds for each scenario
3243                     inputCoreCLRBuildScenario = scenario
3244                 }
3245                 def sourceJobName = getJobName(configuration, architecture, os, inputCoreCLRBuildScenario, false)
3246                 def inputJobName = Utilities.getFullJobName(sourceJobName, isPR)
3247
3248                 // Need to add the sub-folder if necessary.
3249                 def inputJobPath = "job/${inputJobName}"
3250                 def folderName = getJobFolder(inputCoreCLRBuildScenario)
3251                 if (folderName != '') {
3252                     inputJobPath = "job/${folderName}/job/${inputJobName}"
3253                 }
3254
3255                 def inputUrlRoot = "https://ci.dot.net/job/${mungedProjectName}/job/${mungedBranchName}/${inputJobPath}/\${CORECLR_BUILD}/artifact"
3256
3257                 if (isPmiAsmDiffsScenario) {
3258                     def workspaceRelativeRootLinux = "_/pmi"
3259                     shell("mkdir -p ${workspaceRelativeRootLinux}")
3260                     shell("wget --progress=dot:giga ${inputUrlRoot}/product.${os}.${architecture}.${lowerConfiguration}.tgz")
3261                     shell("wget --progress=dot:giga ${inputUrlRoot}/product.baseline.${os}.${architecture}.${lowerConfiguration}.tgz")
3262                     shell("wget --progress=dot:giga ${inputUrlRoot}/coreroot.${os}.${architecture}.${lowerConfiguration}.tgz")
3263                     shell("wget --progress=dot:giga ${inputUrlRoot}/coreroot.baseline.${os}.${architecture}.${lowerConfiguration}.tgz")
3264                 }
3265                 else if (doCoreFxTesting) {
3266                     shell("mkdir -p ${workspaceRelativeFxRootLinux}")
3267                     shell("wget --progress=dot:giga --directory-prefix=${workspaceRelativeFxRootLinux} ${inputUrlRoot}/${workspaceRelativeFxRootLinux}/fxtests.zip")
3268                     shell("wget --progress=dot:giga --directory-prefix=${workspaceRelativeFxRootLinux} ${inputUrlRoot}/${workspaceRelativeFxRootLinux}/fxruntime.zip")
3269                 }
3270                 else {
3271                     def testArtifactsTgzFileName = getTestArtifactsTgzFileName(osGroup, architecture, configuration)
3272                     shell("wget --progress=dot:giga ${inputUrlRoot}/${testArtifactsTgzFileName}")
3273                 }
3274             }
3275
3276             if (architecture == 'x86') {
3277                 shell("mkdir ./bin/CoreFxNative")
3278
3279                 def fxBranch = getFxBranch(branch)
3280                 def corefxFolder = Utilities.getFolderName('dotnet/corefx') + '/' + Utilities.getFolderName(fxBranch)
3281
3282                 copyArtifacts("${corefxFolder}/ubuntu16.04_x86_release") {
3283                     includePatterns('artifacts/bin/build.tar.gz')
3284                     targetDirectory('bin/CoreFxNative')
3285                     buildSelector {
3286                         latestSuccessful(true)
3287                     }
3288                 }
3289
3290                 shell("mkdir ./bin/CoreFxBinDir")
3291                 shell("tar -xf ./bin/CoreFxNative/artifacts/bin/build.tar.gz -C ./bin/CoreFxBinDir")
3292             }
3293
3294             if (isPmiAsmDiffsScenario) {
3295                 shell("tar -xzf ./product.${os}.${architecture}.${lowerConfiguration}.tgz || exit 0")
3296                 shell("tar -xzf ./product.baseline.${os}.${architecture}.${lowerConfiguration}.tgz || exit 0")
3297                 shell("tar -xzf ./coreroot.${os}.${architecture}.${lowerConfiguration}.tgz || exit 0")
3298                 shell("tar -xzf ./coreroot.baseline.${os}.${architecture}.${lowerConfiguration}.tgz || exit 0")
3299             }
3300             // CoreFX testing downloads the CoreFX tests, not the coreclr tests. Also, unzip the built CoreFX layout/runtime directories.
3301             else if (doCoreFxTesting) {
3302                 shell("unzip -q -o ${workspaceRelativeFxRootLinux}/fxtests.zip || exit 0")
3303                 shell("unzip -q -o ${workspaceRelativeFxRootLinux}/fxruntime.zip || exit 0")
3304             }
3305             else {
3306                 def testArtifactsTgzFileName = getTestArtifactsTgzFileName(osGroup, architecture, configuration)
3307                 shell("tar -xzf ./${testArtifactsTgzFileName} || exit 0") // extracts to ./bin/tests/${osGroup}.${architecture}.${configuration}
3308             }
3309
3310             // Execute the tests
3311             def runDocker = isNeedDocker(architecture, os, false)
3312             def dockerPrefix = ""
3313             def dockerCmd = ""
3314             if (runDocker) {
3315                 def dockerImage = getDockerImageName(architecture, os, false)
3316                 dockerPrefix = "docker run -i --rm -v \${WORKSPACE}:\${WORKSPACE} -w \${WORKSPACE} "
3317                 dockerCmd = dockerPrefix + "${dockerImage} "
3318             }
3319
3320             // If we are running a stress mode, we'll set those variables first.
3321             // For CoreFX, the stress variables are already built into the CoreFX test build per-test wrappers.
3322             if (!doCoreFxTesting && isJitStressScenario(scenario)) {
3323                 def scriptFileName = "\${WORKSPACE}/set_stress_test_env.sh"
3324                 def envScriptCmds = envScriptCreate(os, scriptFileName)
3325                 envScriptCmds += envScriptSetStressModeVariables(os, Constants.jitStressModeScenarios[scenario], scriptFileName)
3326                 envScriptCmds += envScriptFinalize(os, scriptFileName)
3327                 shell("${envScriptCmds}")
3328                 testOpts += " --test-env=${scriptFileName}"
3329             }
3330
3331             // setup-stress-dependencies.sh, invoked by runtest.sh to download the coredistools package, depends on the "dotnet"
3332             // tool downloaded by the "init-tools.sh" script. However, it only invokes setup-stress-dependencies.sh for x64. The
3333             // coredistools package is used by GCStress on x86 and x64 to disassemble code to determine instruction boundaries.
3334             // On arm/arm64, it is not required as determining instruction boundaries is trivial.
3335             if (isGCStressRelatedTesting(scenario)) {
3336                 if (architecture == 'x64') {
3337                     shell('./init-tools.sh')
3338                 }
3339             }
3340
3341             if (isPmiAsmDiffsScenario) {
3342                 shell("""\
3343 python -u \${WORKSPACE}/tests/scripts/run-pmi-diffs.py -arch ${architecture} -ci_arch ${architecture} -build_type ${configuration} --skip_baseline_build""")
3344
3345                 shell("tar -czf dasm.${os}.${architecture}.${configuration}.tgz ./_/pmi/asm")
3346             }
3347             else if (doCoreFxTesting) {
3348                 shell("""\
3349 \${WORKSPACE}/tests/scripts/run-corefx-tests.sh --test-exclude-file \${WORKSPACE}/tests/${architecture}/corefx_linux_test_exclusions.txt --runtime \${WORKSPACE}/${workspaceRelativeFxRootLinux}/artifacts/bin/testhost/netcoreapp-Linux-Release-${architecture} --arch ${architecture} --corefx-tests \${WORKSPACE}/${workspaceRelativeFxRootLinux}/artifacts/bin --configurationGroup Release""")
3350             }
3351             else {
3352                 def runScript = "${dockerCmd}./tests/runtest.sh"
3353
3354                 shell("""\
3355 ${runScript} \\
3356     ${lowerConfiguration} \\
3357     --testRootDir=\"\${WORKSPACE}/bin/tests/${osGroup}.${architecture}.${configuration}\" \\
3358     --coreOverlayDir=\"\${WORKSPACE}/bin/tests/${osGroup}.${architecture}.${configuration}/Tests/Core_Root\" \\
3359     --limitedDumpGeneration ${testOpts}""")
3360             }
3361
3362             if (isGcReliabilityFramework(scenario)) {
3363                 // runtest.sh doesn't actually execute the reliability framework - do it here.
3364                 if (useServerGC) {
3365                     if (runDocker) {
3366                         dockerCmd = dockerPrefix + "-e COMPlus_gcServer=1 ${dockerImage} "
3367                     }
3368                     else {
3369                         shell("export COMPlus_gcServer=1")
3370                     }
3371                 }
3372
3373                 shell("${dockerCmd}./tests/scripts/run-gc-reliability-framework.sh ${architecture} ${configuration}")
3374             }
3375         } // steps
3376     } // job
3377
3378     // Experimental: If on Ubuntu 14.04, then attempt to pull in crash dump links
3379     if (os in ['Ubuntu']) {
3380         SummaryBuilder summaries = new SummaryBuilder()
3381         summaries.addLinksSummaryFromFile('Crash dumps from this run:', 'dumplings.txt')
3382         summaries.emit(newJob)
3383     }
3384
3385     if (isPmiAsmDiffsScenario) {
3386         // Archive the asm
3387         Utilities.addArchival(newJob, "dasm.${os}.${architecture}.${configuration}.tgz")
3388     }
3389     else if (doCoreFxTesting) {
3390         Utilities.addArchival(newJob, "${workspaceRelativeFxRootLinux}/artifacts/bin/**/testResults.xml", "", /* doNotFailIfNothingArchived */ true, /* archiveOnlyIfSuccessful */ false)
3391         if ((os == "Ubuntu") && (architecture == 'arm')) {
3392             // We have a problem with the xunit plug-in, where it is consistently failing on Ubuntu arm32 test result uploading with this error:
3393             //
3394             //   [xUnit] [ERROR] - The plugin hasn't been performed correctly: remote file operation failed: /ssd/j/workspace/dotnet_coreclr/master/jitstress/arm_cross_checked_ubuntu_corefx_baseline_tst at hudson.remoting.Channel@3697f46d:JNLP4-connect connection from 131.107.159.149/131.107.159.149:58529: java.io.IOException: Remote call on JNLP4-connect connection from 131.107.159.149/131.107.159.149:58529 failed
3395             //
3396             // We haven't been able to identify the reason. So, do not add xunit parsing of the test data in this scenario.
3397             // This is tracked by: https://github.com/dotnet/coreclr/issues/19447.
3398         }
3399         else {
3400             Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRootLinux}/artifacts/bin/**/testResults.xml")
3401         }
3402     }
3403     else {
3404         Utilities.addXUnitDotNETResults(newJob, '**/coreclrtests.xml')
3405     }
3406
3407     return newJob
3408 }
3409
3410 def static CreateNonWindowsCrossGenComparisonTestJob(def dslFactory, def project, def architecture, def os, def configuration, def scenario, def isPR, def inputCoreCLRBuildName)
3411 {
3412     assert isCrossGenComparisonScenario(scenario)
3413
3414     def osGroup = getOSGroup(os)
3415     def jobName = getJobName(configuration, architecture, os, scenario, false) + "_tst"
3416
3417     def workspaceRelativeResultsDir = "_"
3418     def workspaceRelativeNativeArchResultDir = "${workspaceRelativeResultsDir}/${osGroup}.${architecture}_${architecture}.${configuration}"
3419
3420     def crossArch = "x64"
3421     def workspaceRelativeCrossArchResultDir = "${workspaceRelativeResultsDir}/${osGroup}.${crossArch}_${architecture}.${configuration}"
3422
3423     def jobFolder = getJobFolder(scenario)
3424     def newJob = dslFactory.job(Utilities.getFullJobName(project, jobName, isPR, jobFolder)) {
3425         parameters {
3426             stringParam('CORECLR_BUILD', '', "Build number to copy CoreCLR ${osGroup} binaries from")
3427         }
3428
3429         def workspaceRelativeArtifactsArchive = "${os}.${architecture}.${configuration}.${scenario}.zip"
3430
3431         steps {
3432             copyArtifacts(inputCoreCLRBuildName) {
3433                 includePatterns("${workspaceRelativeArtifactsArchive}")
3434                 buildSelector {
3435                     buildNumber('${CORECLR_BUILD}')
3436                 }
3437             }
3438
3439             shell("unzip -o ${workspaceRelativeArtifactsArchive} || exit 0")
3440
3441             def workspaceRelativeCoreLib = "bin/Product/${osGroup}.${architecture}.${configuration}/IL/System.Private.CoreLib.dll"
3442             def workspaceRelativeCoreRootDir = "bin/tests/${osGroup}.${architecture}.${configuration}/Tests/Core_Root"
3443             def workspaceRelativeCrossGenComparisonScript = "tests/scripts/crossgen_comparison.py"
3444             def workspaceRelativeCrossGenExecutable = "${workspaceRelativeCoreRootDir}/crossgen"
3445
3446             def crossGenComparisonCmd = "python -u \${WORKSPACE}/${workspaceRelativeCrossGenComparisonScript} "
3447             def crossGenExecutable = "\${WORKSPACE}/${workspaceRelativeCrossGenExecutable}"
3448
3449             shell("mkdir -p ${workspaceRelativeNativeArchResultDir}")
3450             shell("${crossGenComparisonCmd}crossgen_corelib --crossgen ${crossGenExecutable} --il_corelib \${WORKSPACE}/${workspaceRelativeCoreLib} --result_dir \${WORKSPACE}/${workspaceRelativeNativeArchResultDir}")
3451             shell("${crossGenComparisonCmd}crossgen_framework --crossgen ${crossGenExecutable} --core_root \${WORKSPACE}/${workspaceRelativeCoreRootDir} --result_dir \${WORKSPACE}/${workspaceRelativeNativeArchResultDir}")
3452
3453             shell("${crossGenComparisonCmd}compare --base_dir \${WORKSPACE}/${workspaceRelativeNativeArchResultDir} --diff_dir \${WORKSPACE}/${workspaceRelativeCrossArchResultDir}")
3454         } // steps
3455     }  // job
3456
3457     Utilities.addArchival(newJob, "${workspaceRelativeNativeArchResultDir}/**", "", /* doNotFailIfNothingArchived */ true, /* archiveOnlyIfSuccessful */ false)
3458     Utilities.addArchival(newJob, "${workspaceRelativeCrossArchResultDir}/**", "", /* doNotFailIfNothingArchived */ true, /* archiveOnlyIfSuccessful */ false)
3459
3460     return newJob
3461 }
3462
3463 // Create a test job that will be used by a flow job.
3464 // Returns the newly created job.
3465 // Note that we don't add tests jobs to the various views, since they are always used by a flow job, which is in the views,
3466 // and we want the views to be the minimal set of "top-level" jobs that represent all work.
3467 def static CreateTestJob(def dslFactory, def project, def branch, def architecture, def os, def configuration, def scenario, def isPR, def inputCoreCLRBuildName)
3468 {
3469     def windowsArmJob = ((os == "Windows_NT") && (architecture in Constants.armWindowsCrossArchitectureList))
3470
3471     def newJob = null
3472     if (windowsArmJob) {
3473         newJob = CreateWindowsArmTestJob(dslFactory, project, architecture, os, configuration, scenario, isPR, inputCoreCLRBuildName)
3474     }
3475     else if (isCrossGenComparisonScenario(scenario)) {
3476         newJob = CreateNonWindowsCrossGenComparisonTestJob(dslFactory, project, architecture, os, configuration, scenario, isPR, inputCoreCLRBuildName)
3477     }
3478     else {
3479         newJob = CreateOtherTestJob(dslFactory, project, branch, architecture, os, configuration, scenario, isPR, inputCoreCLRBuildName)
3480     }
3481
3482     setJobMachineAffinity(architecture, os, false, true, false, newJob) // isBuildJob = false, isTestJob = true, isFlowJob = false
3483
3484     if (scenario == 'jitdiff') {
3485         def osGroup = getOSGroup(os)
3486         Utilities.addArchival(newJob, "bin/tests/${osGroup}.${architecture}.${configuration}/dasm/**")
3487     }
3488
3489     Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
3490     setJobTimeout(newJob, isPR, architecture, configuration, scenario, false)
3491
3492     return newJob
3493 }
3494
3495 // Create a flow job to tie together a build job with the given test job.
3496 // Returns the new flow job.
3497 def static CreateFlowJob(def dslFactory, def project, def branch, def architecture, def os, def configuration, def scenario, def isPR, def fullTestJobName, def inputCoreCLRBuildName)
3498 {
3499     // Windows CoreCLR build and Linux CoreCLR build (in parallel) ->
3500     // Linux CoreCLR test
3501     def flowJobName = getJobName(configuration, architecture, os, scenario, false) + "_flow"
3502     def jobFolder = getJobFolder(scenario)
3503
3504     def newFlowJob = dslFactory.buildFlowJob(Utilities.getFullJobName(project, flowJobName, isPR, jobFolder)) {
3505         buildFlow("""\
3506 coreclrBuildJob = build(params, '${inputCoreCLRBuildName}')
3507
3508 // And then build the test build
3509 build(params + [CORECLR_BUILD: coreclrBuildJob.build.number], '${fullTestJobName}')
3510 """)
3511     }
3512     JobReport.Report.addReference(inputCoreCLRBuildName)
3513     JobReport.Report.addReference(fullTestJobName)
3514
3515     addToViews(newFlowJob, true, isPR, architecture, os, configuration, scenario) // isFlowJob = true
3516
3517     setJobMachineAffinity(architecture, os, false, false, true, newFlowJob) // isBuildJob = false, isTestJob = false, isFlowJob = true
3518
3519     Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
3520     addTriggers(newFlowJob, branch, isPR, architecture, os, configuration, scenario, true, false) // isFlowJob==true, isWindowsBuildOnlyJob==false
3521
3522     return newFlowJob
3523 }
3524
3525 // Determine if we should generate a flow job for the given parameters.
3526 // Returns true if the job should be generated.
3527 def static shouldGenerateFlowJob(def scenario, def isPR, def architecture, def configuration, def os)
3528 {
3529     // The various "innerloop" jobs are only available as PR triggered.
3530
3531     if (!isPR) {
3532         if (isInnerloopTestScenario(scenario)) {
3533             return false
3534         }
3535
3536         if (scenario == 'corefx_innerloop') {
3537             return false
3538         }
3539     }
3540
3541     // Disable flow jobs for innerloop pr.
3542     //
3543     // The only exception is windows arm(64)
3544     if (isInnerloopTestScenario(scenario) && isPR && os != 'Windows_NT') {
3545         assert scenario != 'corefx_innerloop'
3546
3547         return false;
3548     }
3549
3550     // Filter based on OS and architecture.
3551
3552     switch (architecture) {
3553         case 'arm':
3554             if (os != "Ubuntu" && os != "Windows_NT") {
3555                 return false
3556             }
3557             break
3558         case 'arm64':
3559             if (os != "Ubuntu16.04" && os != "Windows_NT") {
3560                 return false
3561             }
3562             break
3563         case 'x86':
3564             if (os != "Ubuntu") {
3565                 return false
3566             }
3567             break
3568         case 'x64':
3569             if (!(os in Constants.crossList)) {
3570                 return false
3571             }
3572             if (os == "Windows_NT") {
3573                 return false
3574             }
3575             break
3576         case 'armem':
3577             // No flow jobs
3578             return false
3579         default:
3580             println("Unknown architecture: ${architecture}")
3581             assert false
3582             break
3583     }
3584
3585     def isNormalOrInnerloop = (scenario == 'innerloop' || scenario == 'normal')
3586
3587     // Filter based on scenario in OS.
3588
3589     if (os == 'Windows_NT') {
3590         assert architecture == 'arm' || architecture == 'arm64'
3591         if (!isArmWindowsScenario(scenario)) {
3592             return false
3593         }
3594         if (isNormalOrInnerloop && (configuration == 'Debug')) {
3595             // The arm32/arm64 Debug configuration for innerloop/normal scenario is a special case: it does a build only, and no test run.
3596             // To do that, it doesn't require a flow job.
3597             return false
3598         }
3599     }
3600     else {
3601         // Non-Windows
3602         if (architecture == 'arm') {
3603             if (!(scenario in Constants.validLinuxArmScenarios)) {
3604                 return false
3605             }
3606         }
3607         else if (architecture == 'arm64') {
3608             if (!(scenario in Constants.validLinuxArm64Scenarios)) {
3609                 return false
3610             }
3611         }
3612         else if (architecture == 'x86') {
3613             // Linux/x86 only want innerloop and default test
3614             if (!isNormalOrInnerloop) {
3615                 return false
3616             }
3617         }
3618         else if (architecture == 'x64') {
3619             // Linux/x64 corefx testing doesn't need a flow job; the "build" job runs run-corefx-tests.py which
3620             // builds and runs the corefx tests. Other Linux/x64 flow jobs are required to get the test
3621             // build from a Windows machine.
3622             if (isCoreFxScenario(scenario)) {
3623                 return false
3624             }
3625         }
3626     }
3627
3628     // For CentOS, we only want Checked/Release builds.
3629     if (os == 'CentOS7.1') {
3630         if (configuration != 'Checked' && configuration != 'Release') {
3631             return false
3632         }
3633         if (!isNormalOrInnerloop && !isR2RScenario(scenario)) {
3634             return false
3635         }
3636     }
3637
3638     // For RedHat and Debian, we only do Release builds.
3639     else if (os == 'RHEL7.2' || os == 'Debian8.4') {
3640         if (configuration != 'Release') {
3641             return false
3642         }
3643         if (!isNormalOrInnerloop) {
3644             return false
3645         }
3646     }
3647
3648     // Next, filter based on scenario.
3649
3650     if (isJitStressScenario(scenario)) {
3651         if (configuration != 'Checked') {
3652             return false
3653         }
3654     }
3655     else if (isR2RBaselineScenario(scenario)) {
3656         if (configuration != 'Checked' && configuration != 'Release') {
3657             return false
3658         }
3659     }
3660     else if (isR2RStressScenario(scenario)) {
3661         if (configuration != 'Checked') {
3662             return false
3663         }
3664     }
3665     else if (isCrossGenComparisonScenario(scenario)) {
3666         return shouldGenerateCrossGenComparisonJob(os, architecture, configuration, scenario)
3667     }
3668     else {
3669         // Skip scenarios
3670         switch (scenario) {
3671             case 'ilrt':
3672             case 'longgc':
3673             case 'gcsimulator':
3674                 // Long GC tests take a long time on non-Release builds
3675                 // ilrt is also Release only
3676                 if (configuration != 'Release') {
3677                     return false
3678                 }
3679                 break
3680
3681             case 'jitdiff':
3682                 if (configuration != 'Checked') {
3683                     return false
3684                 }
3685                 break
3686
3687             case 'gc_reliability_framework':
3688             case 'standalone_gc':
3689                 if (configuration != 'Release' && configuration != 'Checked') {
3690                     return false
3691                 }
3692                 break
3693
3694             case 'formatting':
3695                 return false
3696
3697             case 'illink':
3698                 if (os != 'Windows_NT' && os != 'Ubuntu') {
3699                     return false
3700                 }
3701                 break
3702
3703             case 'normal':
3704                 // Nothing skipped
3705                 break
3706
3707             case 'innerloop':
3708                 if (!isValidPrTriggeredInnerLoopJob(os, architecture, configuration, false)) {
3709                     return false
3710                 }
3711                 break
3712
3713             case 'pmi_asm_diffs':
3714                 if (configuration != 'Checked') {
3715                     return false
3716                 }
3717                 // No need for flow job except for Linux arm/arm64
3718                 if ((os != 'Windows_NT') && (architecture != 'arm') && (architecture != 'arm64')) {
3719                     return false
3720                 }
3721                 break
3722
3723             case 'corefx_innerloop':
3724                 // No flow job needed
3725                 return false
3726
3727             default:
3728                 println("Unknown scenario: ${scenario}")
3729                 assert false
3730                 break
3731         }
3732     }
3733
3734     // The job was not filtered out, so we should generate it!
3735     return true
3736 }
3737
3738 // Create jobs requiring flow jobs. This includes x64 non-Windows, arm/arm64 Ubuntu, and arm/arm64 Windows.
3739 Constants.allScenarios.each { scenario ->
3740     [true, false].each { isPR ->
3741         Constants.architectureList.each { architecture ->
3742             Constants.configurationList.each { configuration ->
3743                 Constants.osList.each { os ->
3744
3745                     if (!shouldGenerateFlowJob(scenario, isPR, architecture, configuration, os)) {
3746                         return
3747                     }
3748
3749                     def windowsArmJob = ((os == "Windows_NT") && (architecture in Constants.armWindowsCrossArchitectureList))
3750                     def doCoreFxTesting = isCoreFxScenario(scenario)
3751                     def doCrossGenComparison = isCrossGenComparisonScenario(scenario)
3752                     def isPmiAsmDiffsScenario = (scenario == 'pmi_asm_diffs')
3753
3754                     // Figure out the job name of the CoreCLR build the test will depend on.
3755
3756                     def inputCoreCLRBuildScenario = isInnerloopTestScenario(scenario) ? 'innerloop' : 'normal'
3757                     def inputCoreCLRBuildIsBuildOnly = false
3758                     if (doCoreFxTesting || isPmiAsmDiffsScenario) {
3759                         // Every CoreFx test depends on its own unique build.
3760                         inputCoreCLRBuildScenario = scenario
3761                         if (windowsArmJob) {
3762                             // Only Windows ARM corefx jobs use "build only" jobs. Others, such as Ubuntu ARM corefx, use "regular" jobs.
3763                             inputCoreCLRBuildIsBuildOnly = true
3764                         }
3765                     }
3766                     else if (doCrossGenComparison) {
3767                         inputCoreCLRBuildScenario = scenario
3768                     }
3769
3770                     def inputCoreCLRFolderName = getJobFolder(inputCoreCLRBuildScenario)
3771                     def inputCoreCLRBuildName = projectFolder + '/' +
3772                         Utilities.getFullJobName(project, getJobName(configuration, architecture, os, inputCoreCLRBuildScenario, inputCoreCLRBuildIsBuildOnly), isPR, inputCoreCLRFolderName)
3773
3774                     // =============================================================================================
3775                     // Create the test job
3776                     // =============================================================================================
3777
3778                     def testJob = CreateTestJob(this, project, branch, architecture, os, configuration, scenario, isPR, inputCoreCLRBuildName)
3779
3780                     // =============================================================================================
3781                     // Create a build flow to join together the build and tests required to run this test.
3782                     // =============================================================================================
3783
3784                     if (os == 'RHEL7.2' || os == 'Debian8.4') {
3785                         // Do not create the flow job for RHEL jobs.
3786                         return
3787                     }
3788
3789                     def fullTestJobName = projectFolder + '/' + testJob.name
3790                     def flowJob = CreateFlowJob(this, project, branch, architecture, os, configuration, scenario, isPR, fullTestJobName, inputCoreCLRBuildName)
3791
3792                 } // os
3793             } // configuration
3794         } // architecture
3795     } // isPR
3796 } // scenario
3797
3798 JobReport.Report.generateJobReport(out)
3799
3800 // Make the call to generate the help job
3801 Utilities.createHelperJob(this, project, branch,
3802     "Welcome to the ${project} Repository",  // This is prepended to the help message
3803     "Have a nice day!")  // This is appended to the help message.  You might put known issues here.
3804
3805 Utilities.addCROSSCheck(this, project, branch)