Fix cross component builderror - CMakeLists.txt for PAL (#9819)
[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
12 folder('jitstress')
13
14 def static getOSGroup(def os) {
15     def osGroupMap = ['Ubuntu':'Linux',
16         'RHEL7.2': 'Linux',
17         'Ubuntu16.04': 'Linux',
18         'Ubuntu16.10': 'Linux',
19         'Debian8.4':'Linux',
20         'Fedora23':'Linux',
21         'OSX':'OSX',
22         'Windows_NT':'Windows_NT',
23         'FreeBSD':'FreeBSD',
24         'CentOS7.1': 'Linux',
25         'OpenSUSE42.1': 'Linux',
26         'LinuxARMEmulator': 'Linux']
27     def osGroup = osGroupMap.get(os, null)
28     assert osGroup != null : "Could not find os group for ${os}"
29     return osGroupMap[os]
30 }
31
32 // We use this class (vs variables) so that the static functions can access data here.
33 class Constants {
34
35     // Innerloop build OS's
36     // The Windows_NT_BuildOnly OS is a way to speed up the Non-NT builds temporarily by avoiding
37     // test execution in the build flow runs.  It generates the exact same build
38     // as Windows_NT but without the tests.
39     def static osList = [
40                'Ubuntu',
41                'Debian8.4',
42                'OSX',
43                'Windows_NT',
44                'Windows_NT_BuildOnly',
45                'FreeBSD',
46                'CentOS7.1',
47                'OpenSUSE42.1',
48                'RHEL7.2',
49                'LinuxARMEmulator',
50                'Ubuntu16.04',
51                'Ubuntu16.10',
52                'Fedora23']
53
54     def static crossList = ['Ubuntu', 'OSX', 'CentOS7.1', 'RHEL7.2', 'Debian8.4']
55
56     // This is a set of JIT stress modes combined with the set of variables that
57     // need to be set to actually enable that stress mode.  The key of the map is the stress mode and
58     // the values are the environment variables
59     def static jitStressModeScenarios = [
60                'minopts'           : ['COMPlus_JITMinOpts' : '1'],
61                'forcerelocs'       : ['COMPlus_ForceRelocs' : '1'],
62                'jitstress1'        : ['COMPlus_JitStress' : '1'],
63                'jitstress2'        : ['COMPlus_JitStress' : '2'],
64                'jitstressregs1'    : ['COMPlus_JitStressRegs' : '1'],
65                'jitstressregs2'    : ['COMPlus_JitStressRegs' : '2'],
66                'jitstressregs3'    : ['COMPlus_JitStressRegs' : '3'],
67                'jitstressregs4'    : ['COMPlus_JitStressRegs' : '4'],
68                'jitstressregs8'    : ['COMPlus_JitStressRegs' : '8'],
69                'jitstressregs0x10' : ['COMPlus_JitStressRegs' : '0x10'],
70                'jitstressregs0x80' : ['COMPlus_JitStressRegs' : '0x80'],
71                'jitstress2_jitstressregs1'    : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '1'],
72                'jitstress2_jitstressregs2'    : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '2'],
73                'jitstress2_jitstressregs3'    : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '3'],
74                'jitstress2_jitstressregs4'    : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '4'],
75                'jitstress2_jitstressregs8'    : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '8'],
76                'jitstress2_jitstressregs0x10' : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '0x10'],
77                'jitstress2_jitstressregs0x80' : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '0x80'],
78                'corefx_baseline'   : [ : ], // corefx baseline
79                'corefx_minopts'    : ['COMPlus_JITMinOpts' : '1'],
80                'corefx_jitstress1' : ['COMPlus_JitStress' : '1'],
81                'corefx_jitstress2' : ['COMPlus_JitStress' : '2'],
82                'corefx_jitstressregs1'    : ['COMPlus_JitStressRegs' : '1'],
83                'corefx_jitstressregs2'    : ['COMPlus_JitStressRegs' : '2'],
84                'corefx_jitstressregs3'    : ['COMPlus_JitStressRegs' : '3'],
85                'corefx_jitstressregs4'    : ['COMPlus_JitStressRegs' : '4'],
86                'corefx_jitstressregs8'    : ['COMPlus_JitStressRegs' : '8'],
87                'corefx_jitstressregs0x10' : ['COMPlus_JitStressRegs' : '0x10'],
88                'corefx_jitstressregs0x80' : ['COMPlus_JitStressRegs' : '0x80'],
89                'gcstress0x3' : ['COMPlus_GCStress' : '0x3'],
90                'gcstress0xc' : ['COMPlus_GCStress' : '0xC'],
91                'zapdisable'  : ['COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0'],
92                'heapverify1' : ['COMPlus_HeapVerify' : '1'],
93                'gcstress0xc_zapdisable'             : ['COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0'],
94                'gcstress0xc_zapdisable_jitstress2'  : ['COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0', 'COMPlus_JitStress'  : '2'],
95                'gcstress0xc_zapdisable_heapverify1' : ['COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0', 'COMPlus_HeapVerify' : '1'],
96                'gcstress0xc_jitstress1'             : ['COMPlus_GCStress' : '0xC', 'COMPlus_JitStress'  : '1'],
97                'gcstress0xc_jitstress2'             : ['COMPlus_GCStress' : '0xC', 'COMPlus_JitStress'  : '2'],
98                'gcstress0xc_minopts_heapverify1'    : ['COMPlus_GCStress' : '0xC', 'COMPlus_JITMinOpts' : '1', 'COMPlus_HeapVerify' : '1']
99                ]
100
101     // This is a set of r2r jit stress scenarios
102     def static r2rJitStressScenarios = [
103                'r2r_jitstress1',
104                'r2r_jitstress2',
105                'r2r_jitstressregs1',
106                'r2r_jitstressregs2',
107                'r2r_jitstressregs3',
108                'r2r_jitstressregs4',
109                'r2r_jitstressregs8',
110                'r2r_jitstressregsx10',
111                'r2r_jitstressregsx80',
112                'r2r_jitminopts',
113                'r2r_jitforcerelocs']
114
115     // This is the basic set of scenarios
116     def static basicScenarios = [
117                'default',
118                'pri1',
119                'ilrt',
120                'r2r',
121                'pri1r2r',
122                'gcstress15_pri1r2r',
123                'longgc',
124                'coverage',
125                'formatting',
126                'gcsimulator',
127                'jitdiff',
128                'standalone_gc'] + r2rJitStressScenarios
129
130     def static configurationList = ['Debug', 'Checked', 'Release']
131
132     // This is the set of architectures
133     def static architectureList = ['arm', 'arm64', 'x64', 'x86', 'x86compatjit', 'x86lb']
134 }
135
136 def static setMachineAffinity(def job, def os, def architecture) {
137     if (architecture == 'arm64' && os == 'Windows_NT') {
138         // For cross compilation
139         job.with {
140             label('arm64')
141         }
142     } else if ((architecture == 'arm' || architecture == 'arm64') && os == 'Ubuntu') {
143         Utilities.setMachineAffinity(job, os, 'arm-cross-latest');
144     } else {
145         Utilities.setMachineAffinity(job, os, 'latest-or-auto');
146     }
147 }
148
149 def static isJITStressJob(def scenario) {
150     return Constants.jitStressModeScenarios.containsKey(scenario) ||
151            (Constants.r2rJitStressScenarios.indexOf(scenario) != -1)
152 }
153
154 def static isGCStressRelatedTesting(def scenario) {
155     // The 'gcstress15_pri1r2r' scenario is a basic scenario.
156     // Detect it and make it a GCStress related.
157     if (scenario == 'gcstress15_pri1r2r')
158     {
159         return true;
160     }
161
162     def gcStressTestEnvVars = [ 'COMPlus_GCStress', 'COMPlus_ZapDisable', 'COMPlus_HeapVerify']
163     def scenarioName = scenario.toLowerCase()
164     def isGCStressTesting = false
165     Constants.jitStressModeScenarios[scenario].each{ k, v ->
166         if (k in gcStressTestEnvVars) {
167             isGCStressTesting = true;
168         }
169     }
170     return isGCStressTesting
171 }
172
173 def static isCorefxTesting(def scenario) {
174     def corefx_prefix = 'corefx_'
175     if (scenario.length() < corefx_prefix.length()) {
176         return false
177     }
178     return scenario.substring(0,corefx_prefix.length()) == corefx_prefix
179 }
180
181 def static isR2R(def scenario) {
182     return (scenario == 'r2r' || scenario == 'pri1r2r')
183 }
184
185 def static isCoverage(def scenario) {
186     return (scenario == 'coverage')
187 }
188
189 def static isLongGc(def scenario) {
190     return (scenario == 'longgc' || scenario == 'gcsimulator')
191 }
192
193 def static isJitDiff(def scenario) {
194     return (scenario == 'jitdiff')
195 }
196
197 def static setTestJobTimeOut(newJob, scenario) {
198     if (isGCStressRelatedTesting(scenario)) {
199         Utilities.setJobTimeout(newJob, 4320)
200     }
201     else if (isCorefxTesting(scenario)) {
202         Utilities.setJobTimeout(newJob, 360)
203     }
204     else if (Constants.jitStressModeScenarios.containsKey(scenario)) {
205         Utilities.setJobTimeout(newJob, 240)
206     }
207     else if (isR2R(scenario)) {
208         Utilities.setJobTimeout(newJob, 240)
209     }
210     else if (isCoverage(scenario)) {
211         Utilities.setJobTimeout(newJob, 1440)
212     }
213     else if (isLongGc(scenario)) {
214         Utilities.setJobTimeout(newJob, 1440)
215     }
216     else if (isJitDiff(scenario)) {
217         Utilities.setJobTimeout(newJob, 240)
218     }
219     // Non-test jobs use the default timeout value.
220 }
221
222 def static getStressModeDisplayName(def scenario) {
223     def displayStr = ''
224     Constants.jitStressModeScenarios[scenario].each{ k, v ->
225         def prefixLength = 'COMPlus_'.length()
226         if (k.length() >= prefixLength) {
227             def modeName = k.substring(prefixLength, k.length())
228             displayStr += ' ' + modeName + '=' + v
229         }
230     }
231     return displayStr
232 }
233
234 // Generates the string for creating a file that sets environment variables
235 // that makes it possible to run stress modes.  Writes the script to the file
236 // specified by the stepScriptLocation parameter.
237 def static genStressModeScriptStep(def os, def stressModeName, def stressModeVars, def stepScriptLocation) {
238     def stepScript = ''
239     if (os == 'Windows_NT') {
240         stepScript += "echo Creating TestEnv Script for ${stressModeName}\r\n"
241         stepScript += "del ${stepScriptLocation}\r\n"
242
243         // Timeout in ms, default is 10 minutes. For stress
244         // modes up this to 30 minutes
245         def timeout = 1800000
246
247         // Set the Timeout
248         stepScript += "set __TestTimeout=${timeout}\r\n"
249         stepScript += "echo. > ${stepScriptLocation}\r\n"
250         stressModeVars.each{ k, v ->
251             // Write out what we are writing to the script file
252             stepScript += "echo Setting ${k}=${v}\r\n"
253             // Write out the set itself to the script file`
254             stepScript += "echo set ${k}=${v} >> ${stepScriptLocation}\r\n"
255         }
256     }
257     else {
258         stepScript += "echo Setting variables for ${stressModeName}\n"
259         stepScript += "echo \\#\\!/usr/bin/env bash > ${stepScriptLocation}\n"
260         stressModeVars.each{ k, v ->
261             // Write out what we are writing to the script file
262             stepScript += "echo Setting ${k}=${v}\n"
263             // Write out the set itself to the script file`
264             stepScript += "echo export ${k}=${v} >> ${stepScriptLocation}\n"
265         }
266         stepScript += "chmod +x ${stepScriptLocation}\n"
267     }
268     return stepScript
269 }
270
271 // Calculates the name of the build job based on some typical parameters.
272 //
273 def static getJobName(def configuration, def architecture, def os, def scenario, def isBuildOnly, def isLinuxEmulatorBuild = false) {
274     // If the architecture is x64, do not add that info into the build name.
275     // Need to change around some systems and other builds to pick up the right builds
276     // to do that.
277
278     def suffix = scenario != 'default' ? "_${scenario}" : '';
279     if (isBuildOnly) {
280         suffix += '_bld'
281     }
282     def baseName = ''
283     switch (architecture) {
284         case 'x64':
285             if (scenario == 'default') {
286                 // For now we leave x64 off of the name for compatibility with other jobs
287                 baseName = configuration.toLowerCase() + '_' + os.toLowerCase()
288             }
289             else if (scenario == 'formatting') {
290                 // we don't care about the configuration for the formatting job. It runs all configs
291                 baseName = architecture.toLowerCase() + '_' + os.toLowerCase()
292             }
293             else {
294                 baseName = architecture.toLowerCase() + '_' + configuration.toLowerCase() + '_' + os.toLowerCase()
295             }
296             break
297         case 'arm64':
298         case 'arm':
299             // These are cross builds
300             if (isLinuxEmulatorBuild == false) {
301                 baseName = architecture.toLowerCase() + '_cross_' + configuration.toLowerCase() + '_' + os.toLowerCase()
302             }
303             else {
304                 baseName = architecture.toLowerCase() + '_emulator_cross_' + configuration.toLowerCase() + '_' + os.toLowerCase()
305             }
306             break
307         case 'x86':
308             baseName = architecture.toLowerCase() + '_' + configuration.toLowerCase() + '_' + os.toLowerCase()
309             break
310         case 'x86compatjit':
311             baseName = 'x86_compatjit_' + configuration.toLowerCase() + '_' + os.toLowerCase()
312             break
313         case 'x86lb':
314             baseName = 'x86_lb_' + configuration.toLowerCase() + '_' + os.toLowerCase()
315             break
316         default:
317             println("Unknown architecture: ${architecture}");
318             assert false
319             break
320     }
321
322     return baseName + suffix
323 }
324
325 def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def os, def configuration, def scenario, def isFlowJob, def isWindowsBuildOnlyJob, def isLinuxEmulatorBuild, def bidailyCrossList) {
326     // Check scenario.
327     switch (scenario) {
328         case 'default':
329             switch (architecture) {
330                 case 'x64':
331                 case 'x86':
332                 case 'x86compatjit':
333                 case 'x86lb':
334                     if (isFlowJob || os == 'Windows_NT' || !(os in Constants.crossList)) {
335                         Utilities.addGithubPushTrigger(job)
336                     }
337                     break
338                 case 'arm':
339                     Utilities.addGithubPushTrigger(job)
340                     break
341                 case 'arm64':
342                     if (os == 'Windows_NT') {
343                         Utilities.addGithubPushTrigger(job)
344                         // TODO: Add once external email sending is available again
345                         // addEmailPublisher(job, 'dotnetonarm64@microsoft.com')
346                     }
347                     break
348                 default:
349                     println("Unknown architecture: ${architecture}");
350                     assert false
351                     break
352             }
353             break
354         case 'pri1':
355             // Pri one gets a push trigger, and only for release
356             if (architecture == 'x64') {
357                 if (configuration == 'Release') {
358                     // We expect release jobs to be Windows, or in the cross list
359                     assert (os == 'Windows_NT') || (os in Constants.crossList)
360                     if (!os in bidailyCrossList) {
361                         if (isFlowJob || os == 'Windows_NT') {
362                             Utilities.addGithubPushTrigger(job)
363                         }
364                     }
365                     else {
366                         if (isFlowJob) {
367                             Utilities.addPeriodicTrigger(job, 'H H/12 * * *')
368                         }
369                     }
370                 }
371             }
372             break
373         case 'r2r':
374             //r2r jobs that aren't pri1 can only be triggered by phrase
375             break
376         case 'pri1r2r':
377             assert !(os in bidailyCrossList)
378             //pri1 r2r gets a push trigger for checked/release
379             if (configuration == 'Checked' || configuration == 'Release') {
380                 assert (os == 'Windows_NT') || (os in Constants.crossList)
381                 if (architecture == 'x64' && os != 'OSX') {
382                     //Flow jobs should be Windows, Ubuntu, OSX, or CentOS
383                     if (isFlowJob || os == 'Windows_NT') {
384                         Utilities.addGithubPushTrigger(job)
385                     }
386                 // OSX pri1r2r jobs should only run every 12 hours, not daily.
387                 } else if (architecture == 'x64' && os == 'OSX'){
388                     if (isFlowJob) {
389                         Utilities.addPeriodicTrigger(job, 'H H/12 * * *')
390                     }
391                 }
392                 // For x86, only add per-commit jobs for Windows
393                 else if (architecture == 'x86' || architecture == 'x86compatjit' || architecture == 'x86lb') {
394                     if (os == 'Windows_NT') {
395                         Utilities.addGithubPushTrigger(job)
396                     }
397                 }
398                 // arm64 pri1r2r jobs should only run every 12 hours.
399                 else if (architecture == 'arm64') {
400                     if (os == 'Windows_NT') {
401                         Utilities.addPeriodicTrigger(job, 'H H/12 * * *')
402                         // TODO: Add once external email sending is available again
403                         // addEmailPublisher(job, 'dotnetonarm64@microsoft.com')
404                     }
405                 }
406             }
407             break
408         case 'r2r_jitstress1':
409         case 'r2r_jitstress2':
410         case 'r2r_jitstressregs1':
411         case 'r2r_jitstressregs2':
412         case 'r2r_jitstressregs3':
413         case 'r2r_jitstressregs4':
414         case 'r2r_jitstressregs8':
415         case 'r2r_jitstressregsx10':
416         case 'r2r_jitstressregsx80':
417         case 'r2r_jitminopts':
418         case 'r2r_jitforcerelocs':
419         case 'gcstress15_pri1r2r':
420             assert !(os in bidailyCrossList)
421
422             // GCStress=C is currently not supported on OS X
423             if (os == 'OSX' && isGCStressRelatedTesting(scenario)) {
424                 break
425             }
426
427             //GC Stress 15 pri1 r2r gets a push trigger for checked/release
428             if (configuration == 'Checked' || configuration == 'Release') {
429                 assert (os == 'Windows_NT') || (os in Constants.crossList)
430                 if (architecture == 'x64') {
431                     //Flow jobs should be Windows, Ubuntu, OSX, or CentOS
432                     if (isFlowJob || os == 'Windows_NT') {
433                         // Add a weekly periodic trigger
434                         Utilities.addPeriodicTrigger(job, 'H H * * 3,6') // some time every Wednesday and Saturday
435                     }
436                 }
437                 // For x86, only add per-commit jobs for Windows
438                 else if (architecture == 'x86' || architecture == 'x86compatjit' || architecture == 'x86lb') {
439                     if (os == 'Windows_NT') {
440                         Utilities.addPeriodicTrigger(job, 'H H * * 3,6') // some time every Wednesday and Saturday
441                     }
442                 }
443             }
444             break
445         case 'longgc':
446             assert (os == 'Ubuntu' || os == 'Windows_NT' || os == 'OSX')
447             assert configuration == 'Release'
448             assert architecture == 'x64'
449             Utilities.addPeriodicTrigger(job, '@daily')
450             // TODO: Add once external email sending is available again
451             // addEmailPublisher(job, 'dotnetgctests@microsoft.com')
452             break
453         case 'gcsimulator':
454             assert (os == 'Ubuntu' || os == 'Windows_NT' || os == 'OSX')
455             assert configuration == 'Release'
456             assert architecture == 'x64'
457             Utilities.addPeriodicTrigger(job, 'H H * * 3,6') // some time every Wednesday and Saturday
458             // TODO: Add once external email sending is available again
459             // addEmailPublisher(job, 'dotnetgctests@microsoft.com')
460             break
461         case 'standalone_gc':
462             assert (os == 'Ubuntu' || os == 'Windows_NT' || os == 'OSX')
463             assert (configuration == 'Release' || configuration == 'Checked')
464             // TODO: Add once external email sending is available again
465             // addEmailPublisher(job, 'dotnetgctests@microsoft.com')
466             Utilities.addPeriodicTrigger(job, '@weekly')
467             break
468         case 'ilrt':
469             assert !(os in bidailyCrossList)
470             // ILASM/ILDASM roundtrip one gets a daily build, and only for release
471             if (architecture == 'x64' && configuration == 'Release') {
472                 // We don't expect to see a job generated except in these scenarios
473                 assert (os == 'Windows_NT') || (os in Constants.crossList)
474                 if (isFlowJob || os == 'Windows_NT') {
475                     Utilities.addPeriodicTrigger(job, '@daily')
476                 }
477             }
478             break
479         case 'jitdiff':
480             assert (os == 'Ubuntu' || os == 'Windows_NT' || os == 'OSX')
481             assert configuration == 'Checked'
482             assert (architecture == 'x64' || architecture == 'x86')
483             Utilities.addGithubPushTrigger(job)
484             break
485         case 'coverage':
486             assert (os == 'Ubuntu' || os == 'Windows_NT')
487             assert configuration == 'Release'
488             assert architecture == 'x64'
489             Utilities.addPeriodicTrigger(job, '@weekly')
490             break
491         case 'formatting':
492             assert (os == 'Windows_NT' || os == "Ubuntu")
493             assert architecture == 'x64'
494             Utilities.addGithubPushTrigger(job)
495             break
496         case 'jitstressregs1':
497         case 'jitstressregs2':
498         case 'jitstressregs3':
499         case 'jitstressregs4':
500         case 'jitstressregs8':
501         case 'jitstressregs0x10':
502         case 'jitstressregs0x80':
503         case 'minopts':
504         case 'forcerelocs':
505         case 'jitstress1':
506         case 'jitstress2':
507         case 'jitstress2_jitstressregs1':
508         case 'jitstress2_jitstressregs2':
509         case 'jitstress2_jitstressregs3':
510         case 'jitstress2_jitstressregs4':
511         case 'jitstress2_jitstressregs8':
512         case 'jitstress2_jitstressregs0x10':
513         case 'jitstress2_jitstressregs0x80':
514         case 'corefx_baseline':
515         case 'corefx_minopts':
516         case 'corefx_jitstress1':
517         case 'corefx_jitstress2':
518         case 'corefx_jitstressregs1':
519         case 'corefx_jitstressregs2':
520         case 'corefx_jitstressregs3':
521         case 'corefx_jitstressregs4':
522         case 'corefx_jitstressregs8':
523         case 'corefx_jitstressregs0x10':
524         case 'corefx_jitstressregs0x80':
525         case 'zapdisable':
526             if (os != 'CentOS7.1' && !(os in bidailyCrossList)) {
527             assert (os == 'Windows_NT') || (os in Constants.crossList)
528             Utilities.addPeriodicTrigger(job, '@daily')
529         }
530         break
531         case 'heapverify1':
532         case 'gcstress0x3':
533             if (os != 'CentOS7.1' && !(os in bidailyCrossList)) {
534                 assert (os == 'Windows_NT') || (os in Constants.crossList)
535                 if (architecture == 'arm64') {
536                     assert (os == 'Windows_NT')
537                     Utilities.addPeriodicTrigger(job, '@daily')
538                     // TODO: Add once external email sending is available again
539                     // addEmailPublisher(job, 'dotnetonarm64@microsoft.com')
540                 }
541                 else {
542                     Utilities.addPeriodicTrigger(job, '@weekly')
543                 }
544             }
545             break
546         case 'gcstress0xc':
547         case 'gcstress0xc_zapdisable':
548         case 'gcstress0xc_zapdisable_jitstress2':
549         case 'gcstress0xc_zapdisable_heapverify1':
550         case 'gcstress0xc_jitstress1':
551         case 'gcstress0xc_jitstress2':
552         case 'gcstress0xc_minopts_heapverify1':
553             // GCStress=C is currently not supported on OS X
554             if (os != 'CentOS7.1' && os != 'OSX' && !(os in bidailyCrossList)) {
555                 assert (os == 'Windows_NT') || (os in Constants.crossList)
556                 if (architecture == 'arm64') {
557                     assert (os == 'Windows_NT')
558                     // TODO: Enable a periodic trigger after tests are updated.
559                     // Utilities.addPeriodicTrigger(job, '@daily')
560                     // TODO: Add once external email sending is available again
561                     // addEmailPublisher(job, 'dotnetonarm64@microsoft.com')
562                 }
563                 else {
564                     Utilities.addPeriodicTrigger(job, '@weekly')
565                 }
566             }
567             break
568         default:
569             println("Unknown scenario: ${scenario}");
570             assert false
571             break
572     }
573     return
574 }
575
576 // **************************
577 // Define the basic inner loop builds for PR and commit.  This is basically just the set
578 // of coreclr builds over linux/osx/freebsd/windows and debug/release/checked.  In addition, the windows
579 // builds will do a couple extra steps.
580 // **************************
581
582 // Adds a trigger for the PR build if one is needed.  If isFlowJob is true, then this is the
583 // flow job that rolls up the build and test for non-windows OS's.  // If the job is a windows build only job,
584 // it's just used for internal builds
585 // If you add a job with a trigger phrase, please add that phrase to coreclr/Documentation/project-docs/ci-trigger-phrases.md
586 def static addTriggers(def job, def branch, def isPR, def architecture, def os, def configuration, def scenario, def isFlowJob, def isWindowsBuildOnlyJob, def isLinuxEmulatorBuild) {
587     if (isWindowsBuildOnlyJob) {
588         return
589     }
590
591     def bidailyCrossList = ['RHEL7.2', 'Debian8.4']
592     // Non pull request builds.
593     if (!isPR) {
594         addNonPRTriggers(job, branch, isPR, architecture, os, configuration, scenario, isFlowJob, isWindowsBuildOnlyJob, isLinuxEmulatorBuild, bidailyCrossList)
595         return
596     }
597     // Pull request builds.  Generally these fall into two categories: default triggers and on-demand triggers
598     // We generally only have a distinct set of default triggers but a bunch of on-demand ones.
599     def osGroup = getOSGroup(os)
600     switch (architecture) {
601         case 'x64': // editor brace matching: {
602             if (scenario == 'coverage') {
603                 assert configuration == 'Release'
604                 if (os == 'Ubuntu') {
605                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Coverage Build & Test", "(?i).*test\\W+coverage.*")
606                 }
607                 break
608             }
609
610             if (scenario == 'formatting') {
611                 assert configuration == 'Checked'
612                 if (os == 'Windows_NT' || os == 'Ubuntu') {
613                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Formatting")
614                 }
615                 break
616             }
617
618             switch (os) {
619                 // OpenSUSE, Debian & RedHat get trigger phrases for pri 0 build, and pri 1 build & test
620                 case 'Debian8.4':
621                 case 'RHEL7.2':
622                     if (scenario == 'default') {
623                         assert !isFlowJob
624                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build", "(?i).*test\\W+${os}.*")
625                     }
626                     else if (scenario == 'pri1' && isFlowJob) {
627                         assert (configuration == 'Release')
628                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Pri 1 Build & Test", "(?i).*test\\W+${os}\\W+${scenario}.*")
629                     }
630                     break
631                 case 'Fedora23':
632                 case 'Ubuntu16.04':
633                 case 'Ubuntu16.10':
634                 case 'OpenSUSE42.1':
635                     assert !isFlowJob
636                     assert scenario == 'default'
637                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build", "(?i).*test\\W+${os}\\W+.*")
638                     break
639                 case 'Ubuntu':
640                 case 'OSX':
641                     // Triggers on the non-flow jobs aren't necessary here
642                     // Corefx testing uses non-flow jobs.
643                     if (!isFlowJob && !isCorefxTesting(scenario)) {
644                         break
645                     }
646                     switch (scenario) {
647                         case 'default':
648                             // Ubuntu uses checked for default PR tests
649                             if (configuration == 'Checked') {
650                                 // Default trigger
651                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test")
652                             }
653                             break
654                         case 'pri1':
655                             if (configuration == 'Release') {
656                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Priority 1 Build and Test", "(?i).*test\\W+${os}\\W+${scenario}.*")
657                             }
658                             break
659                         case 'jitdiff':
660                             if (configuration == 'Checked') {
661                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Jit Diff Build and Test", "(?i).*test\\W+${os}\\W+${scenario}.*")
662                             }
663                             break
664                         case 'ilrt':
665                             if (configuration == 'Release') {
666                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} IL RoundTrip Build and Test", "(?i).*test\\W+${os}\\W+${scenario}.*")
667                             }
668                             break
669                         case 'r2r':
670                             if (configuration == 'Release' || configuration == 'Checked') {
671                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri0 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
672                             }
673                             break
674                         case 'pri1r2r':
675                             if (configuration == 'Release' || configuration == 'Checked') {
676                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri1 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
677                             }
678                             break
679                         case 'gcstress15_pri1r2r':
680                             if (configuration == 'Release' || configuration == 'Checked') {
681                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} GCStress 15 R2R pri1 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
682                             }
683                             break
684                         case 'r2r_jitstress1':
685                             if (configuration == 'Release' || configuration == 'Checked') {
686                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstress1 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
687                             }
688                             break
689                         case 'r2r_jitstress2':
690                             if (configuration == 'Release' || configuration == 'Checked') {
691                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstress2 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
692                             }
693                             break
694                         case 'r2r_jitstressregs1':
695                             if (configuration == 'Release' || configuration == 'Checked') {
696                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs1 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
697                             }
698                             break
699                         case 'r2r_jitstressregs2':
700                             if (configuration == 'Release' || configuration == 'Checked') {
701                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs2 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
702                             }
703                             break
704                         case 'r2r_jitstressregs3':
705                             if (configuration == 'Release' || configuration == 'Checked') {
706                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs3 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
707                             }
708                             break
709                         case 'r2r_jitstressregs4':
710                             if (configuration == 'Release' || configuration == 'Checked') {
711                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs4 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
712                             }
713                             break
714                         case 'r2r_jitstressregs8':
715                             if (configuration == 'Release' || configuration == 'Checked') {
716                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs8 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
717                             }
718                             break
719                         case 'r2r_jitstressregsx10':
720                             if (configuration == 'Release' || configuration == 'Checked') {
721                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregsx10 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
722                             }
723                             break
724                         case 'r2r_jitstressregsx80':
725                             if (configuration == 'Release' || configuration == 'Checked') {
726                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregsx80 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
727                             }
728                             break
729                         case 'r2r_jitminopts':
730                             if (configuration == 'Release' || configuration == 'Checked') {
731                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} JITMinOpts R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
732                             }
733                             break
734                         case 'r2r_jitforcerelocs':
735                             if (configuration == 'Release' || configuration == 'Checked') {
736                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} ForceRelocs R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
737                             }
738                             break
739                         case 'longgc':
740                             if (configuration == 'Release') {
741                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Long-Running GC Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
742                             }
743                             break
744                         case 'gcsimulator':
745                             if (configuration == 'Release') {
746                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} GC Simulator", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
747                             }
748                             break
749                         case 'minopts':
750                             assert (os == 'Windows_NT') || (os in Constants.crossList)
751                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - MinOpts)",
752                                "(?i).*test\\W+${os}\\W+${scenario}.*")
753                             break
754                         case 'jitstress1':
755                             assert (os == 'Windows_NT') || (os in Constants.crossList)
756                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStress=1)",
757                                "(?i).*test\\W+${os}\\W+${scenario}.*")
758                             break
759                         case 'jitstress2':
760                             assert (os == 'Windows_NT') || (os in Constants.crossList)
761                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStress=2)",
762                                "(?i).*test\\W+${os}\\W+${scenario}.*")
763                             break
764                         case 'forcerelocs':
765                             assert (os == 'Windows_NT') || (os in Constants.crossList)
766                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ForceRelocs)",
767                                "(?i).*test\\W+${os}\\W+${scenario}.*")
768                         case 'jitstressregs1':
769                             assert (os == 'Windows_NT') || (os in Constants.crossList)
770                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=1)",
771                                "(?i).*test\\W+${os}\\W+${scenario}.*")
772                             break
773                         case 'jitstressregs2':
774                             assert (os == 'Windows_NT') || (os in Constants.crossList)
775                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=2)",
776                                "(?i).*test\\W+${os}\\W+${scenario}.*")
777                             break
778                         case 'jitstressregs3':
779                             assert (os == 'Windows_NT') || (os in Constants.crossList)
780                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=3)",
781                                "(?i).*test\\W+${os}\\W+${scenario}.*")
782                             break
783                         case 'jitstressregs4':
784                             assert (os == 'Windows_NT') || (os in Constants.crossList)
785                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=4)",
786                                "(?i).*test\\W+${os}\\W+${scenario}.*")
787                             break
788                         case 'jitstressregs8':
789                             assert (os == 'Windows_NT') || (os in Constants.crossList)
790                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=8)",
791                                "(?i).*test\\W+${os}\\W+${scenario}.*")
792                             break
793                         case 'jitstressregs0x10':
794                             assert (os == 'Windows_NT') || (os in Constants.crossList)
795                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=0x10)",
796                                "(?i).*test\\W+${os}\\W+${scenario}.*")
797                             break
798                         case 'jitstressregs0x80':
799                             assert (os == 'Windows_NT') || (os in Constants.crossList)
800                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=0x80)",
801                                "(?i).*test\\W+${os}\\W+${scenario}.*")
802                             break
803                         case 'jitstress2_jitstressregs1':
804                         case 'jitstress2_jitstressregs2':
805                         case 'jitstress2_jitstressregs3':
806                         case 'jitstress2_jitstressregs4':
807                         case 'jitstress2_jitstressregs8':
808                         case 'jitstress2_jitstressregs0x10':
809                         case 'jitstress2_jitstressregs0x80':
810                         case 'gcstress0x3':
811                         case 'gcstress0xc':
812                         case 'zapdisable':
813                         case 'heapverify1':
814                         case 'gcstress0xc_zapdisable':
815                         case 'gcstress0xc_zapdisable_jitstress2':
816                         case 'gcstress0xc_zapdisable_heapverify1':
817                         case 'gcstress0xc_jitstress1':
818                         case 'gcstress0xc_jitstress2':
819                         case 'gcstress0xc_minopts_heapverify1':
820                             def displayStr = getStressModeDisplayName(scenario)
821                             assert (os == 'Windows_NT') || (os in Constants.crossList)
822                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ${displayStr})",
823                                "(?i).*test\\W+${os}\\W+${scenario}.*")
824                             break
825                         case 'corefx_baseline':
826                         case 'corefx_minopts':
827                         case 'corefx_jitstress1':
828                         case 'corefx_jitstress2':
829                         case 'corefx_jitstressregs1':
830                         case 'corefx_jitstressregs2':
831                         case 'corefx_jitstressregs3':
832                         case 'corefx_jitstressregs4':
833                         case 'corefx_jitstressregs8':
834                         case 'corefx_jitstressregs0x10':
835                         case 'corefx_jitstressregs0x80':
836                             def displayName = ('CoreFx ' + getStressModeDisplayName(scenario)).trim()
837                             assert (os == 'Windows_NT') || (os in Constants.crossList)
838                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ${displayName})",
839                                "(?i).*test\\W+${os}\\W+${architecture}\\W+${scenario}.*")
840                             break
841                         default:
842                             println("Unknown scenario: ${scenario}");
843                             assert false
844                             break
845                     }
846                     break
847                 case 'CentOS7.1':
848                     switch (scenario) {
849                         case 'pri1':
850                             if (configuration == 'Release') {
851                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Priority 1 Build and Test", "(?i).*test\\W+${os}\\W+${scenario}.*")
852                             }
853                             break
854                         case 'r2r':
855                             if (configuration == 'Checked' || configuration == 'Release') {
856                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri0 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
857                             }
858                             break
859                         case 'pri1r2r':
860                             if (configuration == 'Checked' || configuration == 'Release') {
861                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri1 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
862                             }
863                             break
864                         case 'gcstress15_pri1r2r':
865                             if (configuration == 'Release' || configuration == 'Checked') {
866                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} GCStress 15 R2R pri1 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
867                             }
868                             break
869                         case 'r2r_jitstress1':
870                             if (configuration == 'Release' || configuration == 'Checked') {
871                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstress1 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
872                             }
873                             break
874                         case 'r2r_jitstress2':
875                             if (configuration == 'Release' || configuration == 'Checked') {
876                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstress2 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
877                             }
878                             break
879                         case 'r2r_jitstressregs1':
880                             if (configuration == 'Release' || configuration == 'Checked') {
881                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs1 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
882                             }
883                             break
884                         case 'r2r_jitstressregs2':
885                             if (configuration == 'Release' || configuration == 'Checked') {
886                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs2 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
887                             }
888                             break
889                         case 'r2r_jitstressregs3':
890                             if (configuration == 'Release' || configuration == 'Checked') {
891                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs3 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
892                             }
893                             break
894                         case 'r2r_jitstressregs4':
895                             if (configuration == 'Release' || configuration == 'Checked') {
896                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs4 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
897                             }
898                             break
899                         case 'r2r_jitstressregs8':
900                             if (configuration == 'Release' || configuration == 'Checked') {
901                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs8 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
902                             }
903                             break
904                         case 'r2r_jitstressregsx10':
905                             if (configuration == 'Release' || configuration == 'Checked') {
906                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregsx10 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
907                             }
908                             break
909                         case 'r2r_jitstressregsx80':
910                             if (configuration == 'Release' || configuration == 'Checked') {
911                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregsx80 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
912                             }
913                             break
914                         case 'r2r_jitminopts':
915                             if (configuration == 'Release' || configuration == 'Checked') {
916                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} JITMinOpts R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
917                             }
918                             break
919                         case 'r2r_jitforcerelocs':
920                             if (configuration == 'Release' || configuration == 'Checked') {
921                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} ForceRelocs R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
922                             }
923                             break
924                         default:
925                             break
926                     }
927                 case 'Windows_NT':
928                     switch (scenario) {
929                         case 'default':
930                             // Default trigger
931                             if (configuration == 'Debug') {
932                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test")
933                             }
934                             break
935                         case 'pri1':
936                             // Default trigger
937                             if (configuration == 'Release') {
938                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Priority 1 Build and Test")
939                             }
940                             break
941                         case 'jitdiff':
942                             if (configuration == 'Checked') {
943                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Jit Diff Build and Test", "(?i).*test\\W+${os}\\W+${scenario}.*")
944                             }
945                             break
946                         case 'ilrt':
947                             if (configuration == 'Release') {
948                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} IL RoundTrip Build and Test", "(?i).*test\\W+${os}\\W+${scenario}.*")
949                             }
950                             break
951                         case 'r2r':
952                             if (configuration == 'Checked' || configuration == 'Release') {
953                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri0 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
954                             }
955                             break
956                         case 'pri1r2r':
957                             if (configuration == 'Checked' || configuration == 'Release') {
958                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri1 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
959                             }
960                             break
961                         case 'gcstress15_pri1r2r':
962                             if (configuration == 'Release' || configuration == 'Checked') {
963                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} GCStress 15 R2R pri1 Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
964                             }
965                             break
966                         case 'r2r_jitstress1':
967                             if (configuration == 'Release' || configuration == 'Checked') {
968                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstress1 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
969                             }
970                             break
971                         case 'r2r_jitstress2':
972                             if (configuration == 'Release' || configuration == 'Checked') {
973                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstress2 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
974                             }
975                             break
976                         case 'r2r_jitstressregs1':
977                             if (configuration == 'Release' || configuration == 'Checked') {
978                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs1 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
979                             }
980                             break
981                         case 'r2r_jitstressregs2':
982                             if (configuration == 'Release' || configuration == 'Checked') {
983                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs2 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
984                             }
985                             break
986                         case 'r2r_jitstressregs3':
987                             if (configuration == 'Release' || configuration == 'Checked') {
988                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs3 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
989                             }
990                             break
991                         case 'r2r_jitstressregs4':
992                             if (configuration == 'Release' || configuration == 'Checked') {
993                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs4 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
994                             }
995                             break
996                         case 'r2r_jitstressregs8':
997                             if (configuration == 'Release' || configuration == 'Checked') {
998                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs8 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
999                             }
1000                             break
1001                         case 'r2r_jitstressregsx10':
1002                             if (configuration == 'Release' || configuration == 'Checked') {
1003                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregsx10 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
1004                             }
1005                             break
1006                         case 'r2r_jitstressregsx80':
1007                             if (configuration == 'Release' || configuration == 'Checked') {
1008                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregsx80 R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
1009                             }
1010                             break
1011                         case 'r2r_jitminopts':
1012                             if (configuration == 'Release' || configuration == 'Checked') {
1013                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} JITMinOpts R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
1014                             }
1015                             break
1016                         case 'r2r_jitforcerelocs':
1017                             if (configuration == 'Release' || configuration == 'Checked') {
1018                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} ForceRelocs R2R Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
1019                             }
1020                             break
1021                         case 'longgc':
1022                             if (configuration == 'Release') {
1023                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Long-Running GC Build & Test", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
1024                             }
1025                             break
1026                         case 'gcsimulator':
1027                             if (configuration == 'Release') {
1028                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} GC Simulator", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
1029                             }
1030                             break
1031                         case 'standalone_gc':
1032                             if (configuration == 'Release' || configuration == 'Checked') {
1033                                 Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Standalone GC", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
1034                             }
1035                             break
1036                         case 'minopts':
1037                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1038                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - MinOpts)",
1039                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1040                             break
1041                         case 'forcerelocs':
1042                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1043                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ForceRelocs)",
1044                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1045                             break
1046                         case 'jitstress1':
1047                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1048                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStress=1)",
1049                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1050                             break
1051                         case 'jitstress2':
1052                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1053                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStress=2)",
1054                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1055                             break
1056                         case 'jitstressregs1':
1057                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1058                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=1)",
1059                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1060                             break
1061                         case 'jitstressregs2':
1062                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1063                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=2)",
1064                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1065                             break
1066                         case 'jitstressregs3':
1067                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1068                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=3)",
1069                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1070                             break
1071                         case 'jitstressregs4':
1072                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1073                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=4)",
1074                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1075                             break
1076                         case 'jitstressregs8':
1077                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1078                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=8)",
1079                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1080                             break
1081                         case 'jitstressregs0x10':
1082                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1083                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=0x10)",
1084                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1085                             break
1086                         case 'jitstressregs0x80':
1087                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1088                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=0x80)",
1089                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1090                             break
1091                         case 'jitstress2_jitstressregs1':
1092                         case 'jitstress2_jitstressregs2':
1093                         case 'jitstress2_jitstressregs3':
1094                         case 'jitstress2_jitstressregs4':
1095                         case 'jitstress2_jitstressregs8':
1096                         case 'jitstress2_jitstressregs0x10':
1097                         case 'jitstress2_jitstressregs0x80':
1098                         case 'gcstress0x3':
1099                         case 'gcstress0xc':
1100                         case 'zapdisable':
1101                         case 'heapverify1':
1102                         case 'gcstress0xc_zapdisable':
1103                         case 'gcstress0xc_zapdisable_jitstress2':
1104                         case 'gcstress0xc_zapdisable_heapverify1':
1105                         case 'gcstress0xc_jitstress1':
1106                         case 'gcstress0xc_jitstress2':
1107                         case 'gcstress0xc_minopts_heapverify1':
1108                             def displayStr = getStressModeDisplayName(scenario)
1109                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1110                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ${displayStr})",
1111                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1112                             break
1113                         case 'corefx_baseline':
1114                         case 'corefx_minopts':
1115                         case 'corefx_jitstress1':
1116                         case 'corefx_jitstress2':
1117                         case 'corefx_jitstressregs1':
1118                         case 'corefx_jitstressregs2':
1119                         case 'corefx_jitstressregs3':
1120                         case 'corefx_jitstressregs4':
1121                         case 'corefx_jitstressregs8':
1122                         case 'corefx_jitstressregs0x10':
1123                         case 'corefx_jitstressregs0x80':
1124                             def displayName = ('CoreFx ' + getStressModeDisplayName(scenario)).trim()
1125                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1126                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ${displayName})",
1127                                "(?i).*test\\W+${os}\\W+${architecture}\\W+${scenario}.*")
1128                             break
1129                         default:
1130                             println("Unknown scenario: ${scenario}");
1131                             assert false
1132                             break
1133                     }
1134                     break
1135                 case 'FreeBSD':
1136                     assert scenario == 'default'
1137                     if (configuration == 'Checked') {
1138                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build")
1139                     }
1140                     break
1141                 default:
1142                     println("Unknown os: ${os}");
1143                     assert false
1144                     break
1145             }
1146             break
1147         // editor brace matching: }
1148         case 'arm': // editor brace matching: {
1149             assert scenario == 'default'
1150             switch (os) {
1151                 case 'Ubuntu':
1152                     if (isLinuxEmulatorBuild == false) {
1153                         // Removing the regex will cause this to run on each PR.
1154                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Build", "(?i).*test\\W+Linux\\W+arm\\W+cross\\W+${configuration}.*")
1155                     }
1156                     else {
1157                         Utilities.addGithubPRTriggerForBranch(job, branch, "Linux ARM Emulator Cross ${configuration} Build")
1158                     }
1159                     break
1160                 case 'Windows_NT':
1161                     if (configuration == 'Debug' || configuration == 'Release')
1162                     {
1163                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Build")
1164                     }
1165                     break
1166                 default:
1167                     println("NYI os: ${os}");
1168                     assert false
1169                     break
1170             }
1171             break
1172         // editor brace matching: }
1173         case 'arm64': // editor brace matching: {
1174             assert (scenario == 'default') || (scenario == 'pri1r2r') || (scenario == 'gcstress0x3') || (scenario == 'gcstress0xc')
1175
1176             // Set up a private trigger
1177             def contextString = "${os} ${architecture} Cross ${configuration}"
1178             if (scenario != 'default')
1179                 contextString += " ${scenario}"
1180             contextString += " Build"
1181             // Debug builds only.
1182             if (configuration != 'Debug') {
1183                contextString += " and Test"
1184             }
1185
1186             def arm64Users = [
1187                 'adiaaida',
1188                 'AndyAyersMS',
1189                 'briansull',
1190                 'BruceForstall',
1191                 'CarolEidt',
1192                 'cmckinsey',
1193                 'erozenfeld',
1194                 'jashook',
1195                 'JosephTremoulet',
1196                 'pgavlin',
1197                 'pkukol',
1198                 'russellhadley',
1199                 'RussKeldorph',
1200                 'sandreenko',
1201                 'sivarv',
1202                 'swaroop-sridhar',
1203                 'gkhanna79',
1204                 'jkotas',
1205                 'markwilkie',
1206                 'rahku',
1207                 'ramarag',
1208                 'tzwlai',
1209                 'weshaggard'
1210             ]
1211
1212             switch (os) {
1213                 case 'Windows_NT':
1214                     switch (scenario) {
1215                         case 'default':
1216                             // For now only run Debug jobs on PR Trigger.
1217                             if (configuration != 'Debug') {
1218                                 Utilities.addPrivateGithubPRTriggerForBranch(job, branch, contextString,
1219                                 "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}.*", null, arm64Users)
1220                             }
1221                             else {
1222                                 // Add "Checked Build And Test" and "Debug Build" to the above users' PRs since many of them
1223                                 // are at higher risk of ARM64-breaking changes.
1224                                 Utilities.addDefaultPrivateGithubPRTriggerForBranch(job, branch, contextString, null, arm64Users)
1225                             }
1226                             break
1227                         case 'pri1r2r':
1228                         case 'gcstress0x3':
1229                         case 'gcstress0xc':
1230                             Utilities.addPrivateGithubPRTriggerForBranch(job, branch, contextString,
1231                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*", null, arm64Users)
1232                             break
1233                     }
1234                     break
1235                 default:
1236                     println("NYI os: ${os}");
1237                     assert false
1238                     break
1239             }
1240             break
1241         // editor brace matching: }
1242         case 'x86': // editor brace matching: {
1243             assert (os == 'Windows_NT')
1244             switch (scenario) {
1245                 case 'default':
1246                     if (configuration == 'Checked') {
1247                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test")
1248                     }
1249                     else if (configuration == 'Release') {
1250                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test",
1251                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}.*")
1252                     }
1253                     break
1254                 case 'pri1':
1255                     if (configuration == 'Release') {
1256                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Priority 1 Build and Test")
1257                     }
1258                     break
1259                 case 'ilrt':
1260                     if (configuration == 'Release') {
1261                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} IL RoundTrip Build and Test",
1262                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1263                     }
1264                     break
1265                 case 'r2r':
1266                     if (configuration == 'Checked' || configuration == 'Release') {
1267                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri0 Build & Test",
1268                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1269                     }
1270                     break
1271                 case 'pri1r2r':
1272                     if (configuration == 'Checked' || configuration == 'Release') {
1273                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri1 Build & Test",
1274                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1275                     }
1276                     break
1277                 case 'gcstress15_pri1r2r':
1278                     if (configuration == 'Release' || configuration == 'Checked') {
1279                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} GCStress 15 R2R pri1 Build & Test",
1280                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1281                     }
1282                     break
1283                 case 'r2r_jitstress1':
1284                     if (configuration == 'Release' || configuration == 'Checked') {
1285                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstress1 R2R Build & Test",
1286                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1287                     }
1288                     break
1289                 case 'r2r_jitstress2':
1290                     if (configuration == 'Release' || configuration == 'Checked') {
1291                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstress2 R2R Build & Test",
1292                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1293                     }
1294                     break
1295                 case 'r2r_jitstressregs1':
1296                     if (configuration == 'Release' || configuration == 'Checked') {
1297                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs1 R2R Build & Test",
1298                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1299                     }
1300                     break
1301                 case 'r2r_jitstressregs2':
1302                     if (configuration == 'Release' || configuration == 'Checked') {
1303                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs2 R2R Build & Test",
1304                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1305                     }
1306                     break
1307                 case 'r2r_jitstressregs3':
1308                     if (configuration == 'Release' || configuration == 'Checked') {
1309                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs3 R2R Build & Test",
1310                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1311                     }
1312                     break
1313                 case 'r2r_jitstressregs4':
1314                     if (configuration == 'Release' || configuration == 'Checked') {
1315                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs4 R2R Build & Test",
1316                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1317                     }
1318                     break
1319                 case 'r2r_jitstressregs8':
1320                     if (configuration == 'Release' || configuration == 'Checked') {
1321                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs8 R2R Build & Test",
1322                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1323                     }
1324                     break
1325                 case 'r2r_jitstressregsx10':
1326                     if (configuration == 'Release' || configuration == 'Checked') {
1327                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregsx10 R2R Build & Test",
1328                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1329                     }
1330                     break
1331                 case 'r2r_jitstressregsx80':
1332                     if (configuration == 'Release' || configuration == 'Checked') {
1333                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregsx80 R2R Build & Test",
1334                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1335                     }
1336                     break
1337                 case 'r2r_jitminopts':
1338                     if (configuration == 'Release' || configuration == 'Checked') {
1339                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} JITMinOpts R2R Build & Test",
1340                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1341                     }
1342                     break
1343                 case 'r2r_jitforcerelocs':
1344                     if (configuration == 'Release' || configuration == 'Checked') {
1345                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} ForceRelocs R2R Build & Test",
1346                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1347                     }
1348                     break
1349                 case 'longgc':
1350                     if (configuration == 'Release') {
1351                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Long-Running GC Build & Test",
1352                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1353                     }
1354                     break
1355                 case 'gcsimulator':
1356                     if (configuration == 'Release') {
1357                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} GC Simulator",
1358                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1359                     }
1360                     break
1361                 case 'standalone_gc':
1362                     if (configuration == 'Release' || configuration == 'Checked') {
1363                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Standalone GC",
1364                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1365                     }
1366                     break
1367                 case 'minopts':
1368                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - MinOpts)",
1369                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1370                     break
1371                 case 'forcerelocs':
1372                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ForceRelocs)",
1373                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1374                     break
1375                 case 'jitstress1':
1376                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStress=1)",
1377                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1378                     break
1379                 case 'jitstress2':
1380                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStress=2)",
1381                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1382                     break
1383                 case 'jitstressregs1':
1384                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=1)",
1385                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1386                     break
1387                 case 'jitstressregs2':
1388                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=2)",
1389                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1390                     break
1391                 case 'jitstressregs3':
1392                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=3)",
1393                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1394                     break
1395                 case 'jitstressregs4':
1396                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=4)",
1397                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1398                     break
1399                 case 'jitstressregs8':
1400                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=8)",
1401                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1402                     break
1403                 case 'jitstressregs0x10':
1404                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=0x10)",
1405                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1406                     break
1407                 case 'jitstressregs0x80':
1408                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=0x80)",
1409                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1410                     break
1411                 case 'jitstress2_jitstressregs1':
1412                 case 'jitstress2_jitstressregs2':
1413                 case 'jitstress2_jitstressregs3':
1414                 case 'jitstress2_jitstressregs4':
1415                 case 'jitstress2_jitstressregs8':
1416                 case 'jitstress2_jitstressregs0x10':
1417                 case 'jitstress2_jitstressregs0x80':
1418                 case 'gcstress0x3':
1419                 case 'gcstress0xc':
1420                 case 'zapdisable':
1421                 case 'heapverify1':
1422                 case 'gcstress0xc_zapdisable':
1423                 case 'gcstress0xc_zapdisable_jitstress2':
1424                 case 'gcstress0xc_zapdisable_heapverify1':
1425                 case 'gcstress0xc_jitstress1':
1426                 case 'gcstress0xc_jitstress2':
1427                 case 'gcstress0xc_minopts_heapverify1':
1428                     def displayStr = getStressModeDisplayName(scenario)
1429                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ${displayStr})",
1430                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1431                     break
1432                 case 'corefx_baseline':
1433                 case 'corefx_minopts':
1434                 case 'corefx_jitstress1':
1435                 case 'corefx_jitstress2':
1436                 case 'corefx_jitstressregs1':
1437                 case 'corefx_jitstressregs2':
1438                 case 'corefx_jitstressregs3':
1439                 case 'corefx_jitstressregs4':
1440                 case 'corefx_jitstressregs8':
1441                 case 'corefx_jitstressregs0x10':
1442                 case 'corefx_jitstressregs0x80':
1443                     def displayName = ('CoreFx ' + getStressModeDisplayName(scenario)).trim()
1444                     assert (os == 'Windows_NT') || (os in Constants.crossList)
1445                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ${displayName})",
1446                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${scenario}.*")
1447                     break
1448                 default:
1449                     println("Unknown scenario: ${os} ${architecture} ${scenario}");
1450                     assert false
1451                     break
1452             }
1453             break
1454         // editor brace matching: }
1455         case 'x86compatjit': // editor brace matching: {
1456             assert (os == 'Windows_NT')
1457             def arch = 'x86'
1458             def jit = 'compatjit'
1459             switch (scenario) {
1460                 case 'default':
1461                     if (configuration == 'Checked') {
1462                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test",
1463                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}.*")
1464                     }
1465                     break
1466                 case 'pri1':
1467                     if (configuration == 'Release') {
1468                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Priority 1 Build and Test",
1469                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+Priority 1 Build and Test.*")
1470                     }
1471                     break
1472                 case 'ilrt':
1473                     if (configuration == 'Release') {
1474                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} IL RoundTrip Build and Test",
1475                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1476                     }
1477                     break
1478                 case 'r2r':
1479                     if (configuration == 'Checked' || configuration == 'Release') {
1480                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} R2R pri0 Build & Test",
1481                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1482                     }
1483                     break
1484                 case 'pri1r2r':
1485                     if (configuration == 'Checked' || configuration == 'Release') {
1486                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} R2R pri1 Build & Test",
1487                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1488                     }
1489                     break
1490                 case 'gcstress15_pri1r2r':
1491                     if (configuration == 'Release' || configuration == 'Checked') {
1492                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} GCStress 15 R2R pri1 Build & Test",
1493                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1494                     }
1495                     break
1496                 case 'r2r_jitstress1':
1497                     if (configuration == 'Release' || configuration == 'Checked') {
1498                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstress1 R2R Build & Test",
1499                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1500                     }
1501                     break
1502                 case 'r2r_jitstress2':
1503                     if (configuration == 'Release' || configuration == 'Checked') {
1504                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstress2 R2R Build & Test",
1505                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1506                     }
1507                     break
1508                 case 'r2r_jitstressregs1':
1509                     if (configuration == 'Release' || configuration == 'Checked') {
1510                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs1 R2R Build & Test",
1511                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1512                     }
1513                     break
1514                 case 'r2r_jitstressregs2':
1515                     if (configuration == 'Release' || configuration == 'Checked') {
1516                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs2 R2R Build & Test",
1517                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1518                     }
1519                     break
1520                 case 'r2r_jitstressregs3':
1521                     if (configuration == 'Release' || configuration == 'Checked') {
1522                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs3 R2R Build & Test",
1523                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1524                     }
1525                     break
1526                 case 'r2r_jitstressregs4':
1527                     if (configuration == 'Release' || configuration == 'Checked') {
1528                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs4 R2R Build & Test",
1529                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1530                     }
1531                     break
1532                 case 'r2r_jitstressregs8':
1533                     if (configuration == 'Release' || configuration == 'Checked') {
1534                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs8 R2R Build & Test",
1535                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1536                     }
1537                     break
1538                 case 'r2r_jitstressregsx10':
1539                     if (configuration == 'Release' || configuration == 'Checked') {
1540                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregsx10 R2R Build & Test",
1541                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1542                     }
1543                     break
1544                 case 'r2r_jitstressregsx80':
1545                     if (configuration == 'Release' || configuration == 'Checked') {
1546                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregsx80 R2R Build & Test",
1547                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1548                     }
1549                     break
1550                 case 'r2r_jitminopts':
1551                     if (configuration == 'Release' || configuration == 'Checked') {
1552                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} JITMinOpts R2R Build & Test",
1553                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1554                     }
1555                     break
1556                 case 'r2r_jitforcerelocs':
1557                     if (configuration == 'Release' || configuration == 'Checked') {
1558                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} ForceRelocs R2R Build & Test",
1559                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1560                     }
1561                     break
1562                 case 'longgc':
1563                     if (configuration == 'Release') {
1564                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Long-Running GC Build & Test",
1565                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1566                     }
1567                     break
1568                 case 'gcsimulator':
1569                     if (configuration == 'Release') {
1570                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} GC Simulator",
1571                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1572                     }
1573                     break
1574                 case 'standalone_gc':
1575                     if (configuration == 'Release' || configuration == 'Checked') {
1576                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Standalone GC", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
1577                     }
1578                     break
1579                 case 'minopts':
1580                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - MinOpts)",
1581                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1582                     break
1583                 case 'forcerelocs':
1584                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - ForceRelocs)",
1585                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1586                     break
1587                 case 'jitstress1':
1588                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStress=1)",
1589                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1590                     break
1591                 case 'jitstress2':
1592                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStress=2)",
1593                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1594                     break
1595                 case 'jitstressregs1':
1596                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=1)",
1597                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1598                     break
1599                 case 'jitstressregs2':
1600                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=2)",
1601                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1602                     break
1603                 case 'jitstressregs3':
1604                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=3)",
1605                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1606                     break
1607                 case 'jitstressregs4':
1608                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=4)",
1609                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1610                     break
1611                 case 'jitstressregs8':
1612                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=8)",
1613                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1614                     break
1615                 case 'jitstressregs0x10':
1616                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=0x10)",
1617                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1618                     break
1619                 case 'jitstressregs0x80':
1620                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=0x80)",
1621                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1622                     break
1623                 case 'jitstress2_jitstressregs1':
1624                 case 'jitstress2_jitstressregs2':
1625                 case 'jitstress2_jitstressregs3':
1626                 case 'jitstress2_jitstressregs4':
1627                 case 'jitstress2_jitstressregs8':
1628                 case 'jitstress2_jitstressregs0x10':
1629                 case 'jitstress2_jitstressregs0x80':
1630                 case 'gcstress0x3':
1631                 case 'gcstress0xc':
1632                 case 'zapdisable':
1633                 case 'heapverify1':
1634                 case 'gcstress0xc_zapdisable':
1635                 case 'gcstress0xc_zapdisable_jitstress2':
1636                 case 'gcstress0xc_zapdisable_heapverify1':
1637                 case 'gcstress0xc_jitstress1':
1638                 case 'gcstress0xc_jitstress2':
1639                 case 'gcstress0xc_minopts_heapverify1':
1640                     def displayStr = getStressModeDisplayName(scenario)
1641                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - ${displayStr})",
1642                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1643                     break
1644                 case 'corefx_baseline':
1645                 case 'corefx_minopts':
1646                 case 'corefx_jitstress1':
1647                 case 'corefx_jitstress2':
1648                 case 'corefx_jitstressregs1':
1649                 case 'corefx_jitstressregs2':
1650                 case 'corefx_jitstressregs3':
1651                 case 'corefx_jitstressregs4':
1652                 case 'corefx_jitstressregs8':
1653                 case 'corefx_jitstressregs0x10':
1654                 case 'corefx_jitstressregs0x80':
1655                     def displayName = ('CoreFx ' + getStressModeDisplayName(scenario)).trim()
1656                     assert (os == 'Windows_NT')
1657                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - ${displayName})",
1658                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1659                     break
1660                 default:
1661                     println("Unknown scenario: ${os} ${arch} ${jit} ${scenario}");
1662                     assert false
1663                     break
1664             }
1665             break
1666         // editor brace matching: }
1667         case 'x86lb': // editor brace matching: {
1668             assert (os == 'Windows_NT')
1669             assert (scenario == 'default' ||
1670                     scenario == 'r2r' ||
1671                     scenario == 'pri1r2r' ||
1672                     scenario == 'gcstress15_pri1r2r' ||
1673                     scenario == 'longgc' ||
1674                     scenario == 'gcsimulator' ||
1675                     Constants.r2rJitStressScenarios.indexOf(scenario) != -1)
1676
1677             def arch = 'x86'
1678             def jit = 'legacy_backend'
1679             switch (scenario) {
1680                 case 'default':
1681                     if (configuration == 'Checked') {
1682                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test",
1683                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}.*")
1684                     }
1685                     break
1686                 case 'r2r':
1687                     if (configuration == 'Release') {
1688                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} R2R pri0 Build & Test",
1689                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1690                     }
1691                     break
1692                 case 'pri1r2r':
1693                     if (configuration == 'Release') {
1694                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} R2R pri1 Build & Test",
1695                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1696                     }
1697                     break
1698                 case 'gcstress15_pri1r2r':
1699                     if (configuration == 'Release') {
1700                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} GCStress 15 R2R pri1 Build & Test",
1701                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1702                     }
1703                     break
1704                 case 'r2r_jitstress1':
1705                     if (configuration == 'Release' || configuration == 'Checked') {
1706                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstress1 R2R Build & Test",
1707                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1708                     }
1709                     break
1710                 case 'r2r_jitstress2':
1711                     if (configuration == 'Release' || configuration == 'Checked') {
1712                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstress2 R2R Build & Test",
1713                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1714                     }
1715                     break
1716                 case 'r2r_jitstressregs1':
1717                     if (configuration == 'Release' || configuration == 'Checked') {
1718                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs1 R2R Build & Test",
1719                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1720                     }
1721                     break
1722                 case 'r2r_jitstressregs2':
1723                     if (configuration == 'Release' || configuration == 'Checked') {
1724                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs2 R2R Build & Test",
1725                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1726                     }
1727                     break
1728                 case 'r2r_jitstressregs3':
1729                     if (configuration == 'Release' || configuration == 'Checked') {
1730                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs3 R2R Build & Test",
1731                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1732                     }
1733                     break
1734                 case 'r2r_jitstressregs4':
1735                     if (configuration == 'Release' || configuration == 'Checked') {
1736                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs4 R2R Build & Test",
1737                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1738                     }
1739                     break
1740                 case 'r2r_jitstressregs8':
1741                     if (configuration == 'Release' || configuration == 'Checked') {
1742                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs8 R2R Build & Test",
1743                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1744                     }
1745                     break
1746                 case 'r2r_jitstressregsx10':
1747                     if (configuration == 'Release' || configuration == 'Checked') {
1748                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregsx10 R2R Build & Test",
1749                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1750                     }
1751                     break
1752                 case 'r2r_jitstressregsx80':
1753                     if (configuration == 'Release' || configuration == 'Checked') {
1754                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregsx80 R2R Build & Test",
1755                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1756                     }
1757                     break
1758                 case 'r2r_jitminopts':
1759                     if (configuration == 'Release' || configuration == 'Checked') {
1760                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitminopts R2R Build & Test",
1761                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1762                     }
1763                     break
1764                 case 'r2r_jitforcerelocs':
1765                     if (configuration == 'Release' || configuration == 'Checked') {
1766                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitforcerelocs R2R Build & Test",
1767                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1768                     }
1769                     break
1770                 case 'longgc':
1771                     if (configuration == 'Release') {
1772                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Long-Running GC Build & Test",
1773                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1774                     }
1775                     break
1776                 case 'gcsimulator':
1777                     if (configuration == 'Release') {
1778                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} GC Simulator",
1779                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1780                     }
1781                     break
1782                 case 'standalone_gc':
1783                     if (configuration == 'Release' || configuration == 'Checked') {
1784                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Standalone GC", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
1785                     }
1786                     break
1787                 default:
1788                     println("Unknown scenario: ${os} ${arch} ${jit} ${scenario}");
1789                     assert false
1790                     break
1791             }
1792             break
1793         // editor brace matching: }
1794         default:
1795             println("Unknown architecture: ${architecture}");
1796             assert false
1797             break
1798     }
1799 }
1800
1801 def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR, def architecture, def configuration, def os, def enableCorefxTesting, def isBuildOnly, def isLinuxEmulatorBuild) {
1802     def buildCommands = [];
1803     def osGroup = getOSGroup(os)
1804     def lowerConfiguration = configuration.toLowerCase()
1805
1806     // Calculate the build steps, archival, and xunit results
1807     switch (os) {
1808         case 'Windows_NT': // editor brace matching: {
1809             switch (architecture) {
1810                 case 'x64':
1811                 case 'x86':
1812                 case 'x86compatjit':
1813                 case 'x86lb':
1814                     def arch = architecture
1815                     def buildOpts = ''
1816
1817                     // We need to explicitly run build-test.cmd with Exclude for x86compatjit and x86lb, so skip tests.
1818                     if (architecture == 'x86compatjit') {
1819                         arch = 'x86'
1820                         buildOpts = 'compatjitcrossgen skiptests'
1821                     }
1822                     else if (architecture == 'x86lb') {
1823                         arch = 'x86'
1824                         buildOpts = 'legacyjitcrossgen skiptests'
1825                     }
1826
1827                     if (Constants.jitStressModeScenarios.containsKey(scenario) ||
1828                             scenario == 'default' ||
1829                             scenario == 'r2r' ||
1830                             scenario == 'jitdiff' ||
1831                             Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
1832                         buildOpts += enableCorefxTesting ? ' skiptests' : ''
1833                         buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${arch} ${buildOpts}"
1834                     }
1835
1836                     // For Pri 1 tests, we must shorten the output test binary path names.
1837                     // if __TestIntermediateDir is already set, build-test.cmd will
1838                     // output test binaries to that directory. If it is not set, the
1839                     // binaries are sent to a default directory whose name is about
1840                     // 35 characters long.
1841
1842                     else if (scenario == 'pri1' || scenario == 'pri1r2r' || scenario == 'gcstress15_pri1r2r'|| scenario == 'coverage') {
1843                         buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${arch} ${buildOpts} -priority=1"
1844                     }
1845                     else if (scenario == 'ilrt') {
1846                         // First do the build with skiptests and then build the tests with ilasm roundtrip
1847                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} ${buildOpts} skiptests"
1848                         buildCommands += "set __TestIntermediateDir=int&&build-test.cmd ${lowerConfiguration} ${arch} -ilasmroundtrip"
1849                     }
1850                     else if (isLongGc(scenario)) {
1851                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} ${buildOpts} skiptests"
1852                         buildCommands += "set __TestIntermediateDir=int&&build-test.cmd ${lowerConfiguration} ${arch}"
1853                     }
1854                     else if (scenario == 'standalone_gc') {
1855                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} ${buildOpts} buildstandalonegc"
1856                     }
1857                     else if (scenario == 'formatting') {
1858                         buildCommands += "python -u tests\\scripts\\format.py -c %WORKSPACE% -o Windows_NT -a ${arch}"
1859                         Utilities.addArchival(newJob, "format.patch", "", true, false)
1860                         break
1861                     }
1862                     else {
1863                         println("Unknown scenario: ${scenario}")
1864                         assert false
1865                     }
1866
1867                     // If we are running a stress mode, we should write out the set of key
1868                     // value env pairs to a file at this point and then we'll pass that to runtest.cmd
1869
1870                     if (!isBuildOnly) {
1871                         //If this is a crossgen build, pass 'crossgen' to runtest.cmd
1872                         def crossgenStr = ''
1873                         def runcrossgentestsStr = ''
1874                         def runjitstressStr = ''
1875                         def runjitstressregsStr = ''
1876                         def runjitmioptsStr = ''
1877                         def runjitforcerelocsStr = ''
1878                         def runjitdisasmStr = ''
1879                         def gcstressStr = ''
1880                         def runtestArguments = ''
1881                         def gcTestArguments = ''
1882
1883                         if (scenario == 'r2r' ||
1884                             scenario == 'pri1r2r' ||
1885                             scenario == 'gcstress15_pri1r2r' ||
1886                             Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
1887                                 crossgenStr = 'crossgen'
1888                                 runcrossgentestsStr = 'runcrossgentests'
1889
1890                                 if (scenario == 'r2r_jitstress1'){
1891                                     runjitstressStr = 'jitstress 1'
1892                                 }
1893                                 else if (scenario == 'r2r_jitstress2') {
1894                                     runjitstressStr = 'jitstress 2'
1895                                 }
1896                                 else if (scenario == 'r2r_jitstressregs1'){
1897                                     runjitstressregsStr = 'jitstressregs 1'
1898                                 }
1899                                 else if (scenario == 'r2r_jitstressregs2') {
1900                                     runjitstressregsStr = 'jitstressregs 2'
1901                                 }
1902                                 else if (scenario == 'r2r_jitstressregs3') {
1903                                     runjitstressregsStr = 'jitstressregs 3'
1904                                 }
1905                                 else if (scenario == 'r2r_jitstressregs4') {
1906                                     runjitstressregsStr = 'jitstressregs 4'
1907                                 }
1908                                 else if (scenario == 'r2r_jitstressregs8') {
1909                                     runjitstressregsStr = 'jitstressregs 8'
1910                                 }
1911                                 else if (scenario == 'r2r_jitstressregsx10') {
1912                                     runjitstressregsStr = 'jitstressregs x10'
1913                                 }
1914                                 else if (scenario == 'r2r_jitstressregsx80') {
1915                                     runjitstressregsStr = 'jitstressregs x80'
1916                                 }
1917                                 else if (scenario == 'r2r_jitminopts') {
1918                                     runjitmioptsStr = 'jitminopts'
1919                                 }
1920                                 else if (scenario == 'r2r_jitforcerelocs') {
1921                                     runjitforcerelocsStr = 'jitforcerelocs'
1922                                 }
1923                         }
1924                         if (scenario == 'gcstress15_pri1r2r')
1925                         {
1926                             gcstressStr = 'gcstresslevel 0xF'
1927                         }
1928
1929                         if (scenario == 'jitdiff')
1930                         {
1931                             runjitdisasmStr = 'jitdisasm crossgen'
1932                         }
1933
1934                         if (isLongGc(scenario)) {
1935                             gcTestArguments = "${scenario} sequential"
1936                         }
1937
1938                         runtestArguments = "${lowerConfiguration} ${arch} ${gcstressStr} ${crossgenStr} ${runcrossgentestsStr} ${runjitstressStr} ${runjitstressregsStr} ${runjitmioptsStr} ${runjitforcerelocsStr} ${runjitdisasmStr} ${gcTestArguments}"
1939
1940                         if (Constants.jitStressModeScenarios.containsKey(scenario)) {
1941                             def stepScriptLocation = "%WORKSPACE%\\SetStressModes.bat"
1942                             buildCommands += genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios[scenario], stepScriptLocation)
1943
1944                             if (enableCorefxTesting) {
1945                                 def workspaceRelativeFxRoot = "_/fx"
1946                                 def absoluteFxRoot = "%WORKSPACE%\\_\\fx"
1947
1948                                 buildCommands += "python -u %WORKSPACE%\\tests\\scripts\\run-corefx-tests.py -arch ${arch} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${branch} -env_script ${stepScriptLocation}"
1949
1950                                 setTestJobTimeOut(newJob, scenario)
1951
1952                                 // Archive and process (only) the test results
1953                                 Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
1954                                 Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
1955                             }
1956                             else {
1957                                 buildCommands += "%WORKSPACE%\\tests\\runtest.cmd ${runtestArguments} TestEnv ${stepScriptLocation}"
1958                             }
1959                         }
1960                         else if (architecture == 'x64' || architecture == 'x86') {
1961                             buildCommands += "tests\\runtest.cmd ${runtestArguments}"
1962                         }
1963                         else if (architecture == 'x86compatjit') {
1964                             def testEnvLocation = "%WORKSPACE%\\tests\\x86\\compatjit_x86_testenv.cmd"
1965                             def excludeLocation = "%WORKSPACE%\\tests\\x86_legacy_backend_issues.targets"
1966                             buildCommands += "build-test.cmd ${runtestArguments} Exclude ${excludeLocation}"
1967                             buildCommands += "tests\\runtest.cmd ${runtestArguments} TestEnv ${testEnvLocation}"
1968                         }
1969                         else if (architecture == 'x86lb') {
1970                             def testEnvLocation = "%WORKSPACE%\\tests\\x86\\legacyjit_x86_testenv.cmd"
1971                             def excludeLocation = "%WORKSPACE%\\tests\\x86_legacy_backend_issues.targets"
1972                             buildCommands += "build-test.cmd ${runtestArguments} Exclude ${excludeLocation}"
1973                             buildCommands += "tests\\runtest.cmd ${runtestArguments} TestEnv ${testEnvLocation}"
1974                         }
1975                     }
1976
1977                     if (!enableCorefxTesting) {
1978                         // Run the rest of the build
1979                         // Build the mscorlib for the other OS's
1980                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} linuxmscorlib"
1981                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} freebsdmscorlib"
1982                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} osxmscorlib"
1983
1984                         // Zip up the tests directory so that we don't use so much space/time copying
1985                         // 10s of thousands of files around.
1986                         buildCommands += "powershell -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${arch}.${configuration}', '.\\bin\\tests\\tests.zip')\"";
1987
1988                         if (!Constants.jitStressModeScenarios.containsKey(scenario)) {
1989                             // For windows, pull full test results and test drops for x86/x64.
1990                             // No need to pull for stress mode scenarios (downstream builds use the default scenario)
1991                             Utilities.addArchival(newJob, "bin/Product/**,bin/tests/tests.zip")
1992                         }
1993
1994                         if (scenario == 'jitdiff') {
1995                             // retrive jit-dasm output for base commit, and run jit-diff
1996                             if (!isBuildOnly) {
1997                                 // if this is a build only job, we want to keep the default (build) artifacts for the flow job
1998                                 Utilities.addArchival(newJob, "bin/tests/${osGroup}.${arch}.${configuration}/dasm/**")
1999                             }
2000                         }
2001
2002                         if (!isBuildOnly) {
2003                             if (architecture == 'x64' || !isPR) {
2004                                 Utilities.addXUnitDotNETResults(newJob, 'bin/**/TestRun*.xml')
2005                             }
2006                             setTestJobTimeOut(newJob, scenario)
2007                         }
2008                     }
2009                     break
2010                 case 'arm':
2011                     assert (scenario == 'default')
2012
2013                     // Set time out
2014                     setTestJobTimeOut(newJob, scenario)
2015
2016                     if ( lowerConfiguration == "debug" ) {
2017                         // For Debug builds, we will do a P1 test build
2018                         buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} -priority=1"
2019                     }
2020                     else {
2021                         buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture}"
2022                     }
2023                     // Add archival.
2024                     Utilities.addArchival(newJob, "bin/Product/**")
2025                     break
2026                 case 'arm64':
2027                     assert (scenario == 'default') || (scenario == 'pri1r2r') || (scenario == 'gcstress0x3') || (scenario == 'gcstress0xc')
2028                    
2029                     // Set time out
2030                     setTestJobTimeOut(newJob, scenario)
2031
2032                     // Debug runs take too long to run. So build job only.
2033                     if (lowerConfiguration == "debug") {
2034                        buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} toolset_dir C:\\ats2"
2035                     }
2036                     else {
2037                        if ((scenario != 'gcstress0x3') && (scenario != 'gcstress0xc'))
2038                        {
2039                            // Up the timeout for arm64 checked testing only.
2040                            // Keep the longer timeout for gcstress.
2041                            Utilities.setJobTimeout(newJob, 240)
2042                        }
2043
2044                        buildCommands += "set __TestIntermediateDir=int&&build.cmd skiptests ${lowerConfiguration} ${architecture} toolset_dir C:\\ats2"
2045                        // Test build and run are launched together.
2046                        buildCommands += "python tests\\scripts\\arm64_post_build.py -repo_root %WORKSPACE% -arch ${architecture} -build_type ${lowerConfiguration} -scenario ${scenario} -key_location C:\\tools\\key.txt"
2047                        //Utilities.addXUnitDotNETResults(newJob, 'bin/tests/testResults.xml')
2048                     }
2049
2050                     // Add archival.
2051                     Utilities.addArchival(newJob, "bin/Product/**")
2052                     break
2053                 default:
2054                     println("Unknown architecture: ${architecture}");
2055                     assert false
2056                     break
2057             }
2058             break
2059         // editor brace matching: }
2060         case 'Ubuntu':
2061         case 'Ubuntu16.04':
2062         case 'Ubuntu16.10':
2063         case 'Debian8.4':
2064         case 'OSX':
2065         case 'FreeBSD':
2066         case 'CentOS7.1':
2067         case 'RHEL7.2':
2068         case 'OpenSUSE42.1':
2069         case 'Fedora23': // editor brace matching: {
2070             switch (architecture) {
2071                 case 'x64':
2072                 case 'x86':
2073                 case 'x86compatjit':
2074                 case 'x86lb':
2075                     def arch = architecture
2076                     if (architecture == 'x86compatjit' || architecture == 'x86lb') {
2077                         arch = 'x86'
2078                     }
2079
2080                     if (scenario == 'formatting') {
2081                         buildCommands += "python tests/scripts/format.py -c \${WORKSPACE} -o Linux -a ${arch}"
2082                         Utilities.addArchival(newJob, "format.patch", "", true, false)
2083                         break
2084                     }
2085
2086                     def standaloneGc = ''
2087                     if (scenario == 'standalone_gc') {
2088                         standaloneGc = 'buildstandalonegc'
2089                     }
2090
2091                     if (!enableCorefxTesting) {
2092                         // We run pal tests on all OS but generate mscorlib (and thus, nuget packages)
2093                         // only on supported OS platforms.
2094                         if (os == 'FreeBSD')
2095                         {
2096                             buildCommands += "./build.sh skipmscorlib verbose ${lowerConfiguration} ${arch} ${standaloneGc}"
2097                         }
2098                         else
2099                         {
2100                             def bootstrapRid = Utilities.getBoostrapPublishRid(os)
2101                             def bootstrapRidEnv = bootstrapRid != null ? "__PUBLISH_RID=${bootstrapRid} " : ''
2102                             buildCommands += "${bootstrapRidEnv}./build.sh verbose ${lowerConfiguration} ${arch} ${standaloneGc}"
2103                         }
2104                         buildCommands += "src/pal/tests/palsuite/runpaltests.sh \${WORKSPACE}/bin/obj/${osGroup}.${arch}.${configuration} \${WORKSPACE}/bin/paltestout"
2105
2106                         // Set time out
2107                         setTestJobTimeOut(newJob, scenario)
2108                         // Basic archiving of the build
2109                         Utilities.addArchival(newJob, "bin/Product/**,bin/obj/*/tests/**/*.dylib,bin/obj/*/tests/**/*.so")
2110                         // And pal tests
2111                         Utilities.addXUnitDotNETResults(newJob, '**/pal_tests.xml')
2112                     }
2113                     else {
2114                         // Corefx stress testing
2115                         assert os == 'Ubuntu'
2116                         assert architecture == 'x64'
2117                         assert lowerConfiguration == 'checked'
2118                         assert Constants.jitStressModeScenarios.containsKey(scenario)
2119
2120                         // Build coreclr
2121                         buildCommands += "./build.sh verbose ${lowerConfiguration} ${architecture}"
2122
2123                         def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
2124                         buildCommands += genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios[scenario], scriptFileName)
2125
2126                         // Build and text corefx
2127                         def workspaceRelativeFxRoot = "_/fx"
2128                         def absoluteFxRoot = "\$WORKSPACE/${workspaceRelativeFxRoot}"
2129
2130                         buildCommands += "python -u \$WORKSPACE/tests/scripts/run-corefx-tests.py -arch ${arch} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${branch} -env_script ${scriptFileName}"
2131
2132                         setTestJobTimeOut(newJob, scenario)
2133
2134                         // Archive and process (only) the test results
2135                         Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
2136                         Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml")
2137                     }
2138                     break
2139                 case 'arm64':
2140                     // We don't run the cross build except on Ubuntu
2141                     assert os == 'Ubuntu'
2142
2143                     buildCommands += """echo \"Using rootfs in /opt/aarch64-linux-gnu-root\"
2144                         ROOTFS_DIR=/opt/aarch64-linux-gnu-root ./build.sh skipmscorlib arm64 cross verbose ${lowerConfiguration}"""
2145
2146                     // Basic archiving of the build, no pal tests
2147                     Utilities.addArchival(newJob, "bin/Product/**")
2148                     break
2149                 case 'arm':
2150                     // All builds for ARM architecture are run on Ubuntu currently
2151                     assert os == 'Ubuntu'
2152                     if (isLinuxEmulatorBuild == false) {
2153                         buildCommands += """echo \"Using rootfs in /opt/arm-liux-genueabihf-root\"
2154                             ROOTFS_DIR=/opt/arm-linux-genueabihf-root ./build.sh skipmscorlib arm cross verbose ${lowerConfiguration}"""
2155
2156                         // Basic archiving of the build, no pal tests
2157                         Utilities.addArchival(newJob, "bin/Product/**")
2158                         break
2159                     }
2160                     else {
2161                         // Make sure the build configuration is either of debug or release
2162                         assert ( lowerConfiguration == 'debug' ) || ( lowerConfiguration == 'release' )
2163
2164                         // Setup variables to hold emulator folder path and the rootfs mount path
2165                         def armemul_path = '/opt/linux-arm-emulator'
2166                         def armrootfs_mountpath = '/opt/linux-arm-emulator-root'
2167
2168                         // Unzip the Windows test binaries first. Exit with 0
2169                         buildCommands += "unzip -q -o ./bin/tests/tests.zip -d ./bin/tests/Windows_NT.x64.${configuration} || exit 0"
2170
2171                         // Unpack the corefx binaries
2172                         buildCommands += "mkdir ./bin/CoreFxBinDir"
2173                         buildCommands += "tar -xf ./bin/build.tar.gz -C ./bin/CoreFxBinDir"
2174
2175                         // Call the ARM emulator build script to cross build and test using the ARM emulator rootfs
2176                         buildCommands += """./tests/scripts/arm32_ci_script.sh \\
2177                         --emulatorPath=${armemul_path} \\
2178                         --mountPath=${armrootfs_mountpath} \\
2179                         --buildConfig=${lowerConfiguration} \\
2180                         --testRootDir=./bin/tests/Windows_NT.x64.${configuration} \\
2181                         --coreFxNativeBinDir=./bin/Linux.armel.${configuration} \\
2182                         --coreFxBinDir=\"./bin/Linux.AnyCPU.${configuration};./bin/Unix.AnyCPU.${configuration};./bin/AnyOS.AnyCPU.${configuration}\" \\
2183                         --testDirFile=./tests/testsRunningInsideARM.txt"""
2184
2185
2186                         // Basic archiving of the build
2187                         Utilities.addArchival(newJob, "bin/Product/**")
2188                         break
2189                     }
2190                 default:
2191                     println("Unknown architecture: ${architecture}");
2192                     assert false
2193                     break
2194             }
2195             break
2196         // editor brace matching: }
2197         default:
2198             println("Unknown os: ${os}");
2199             assert false
2200             break
2201     } // os
2202
2203     return buildCommands
2204 }
2205
2206 // Additional scenario which can alter behavior
2207
2208 def combinedScenarios = Constants.basicScenarios + Constants.jitStressModeScenarios.keySet()
2209 combinedScenarios.each { scenario ->
2210     [true, false].each { isPR ->
2211         Constants.architectureList.each { architecture ->
2212             Constants.configurationList.each { configuration ->
2213                 Constants.osList.each { os ->
2214                     // If the OS is Windows_NT_BuildOnly, set the isBuildOnly flag to true
2215                     // and reset the os to Windows_NT
2216                     def isBuildOnly = false
2217                     if (os == 'Windows_NT_BuildOnly') {
2218                         isBuildOnly = true
2219                         os = 'Windows_NT'
2220                     }
2221
2222                     // WinArm32 is only built for Debug and Release
2223                     if (os == 'Windows_NT' && architecture == 'arm')
2224                     {
2225                         if (configuration == 'Checked')
2226                         {
2227                             return
2228                         }
2229                     }
2230                     // If the OS is LinuxARMEmulator and arch is arm, set the isLinuxEmulatorBuild
2231                     // flag to true and reset the os to Ubuntu
2232                     // The isLinuxEmulatorBuild flag will be used at a later time to execute the right
2233                     // set of build commands
2234                     // The tuples (LinuxARMEmulator, other architectures) are not handled and control returns
2235                     def isLinuxEmulatorBuild = false
2236                     if (os == 'LinuxARMEmulator' && architecture == 'arm') {
2237                         // Cross Builds only in Debug and Release modes allowed
2238                         if ( configuration == 'Checked' ) {
2239                             return
2240                         }
2241
2242                         isLinuxEmulatorBuild = true
2243                         os = 'Ubuntu'
2244                     } else if (os == 'LinuxARMEmulator') {
2245                         return
2246                     }
2247
2248                     // Skip totally unimplemented (in CI) configurations.
2249                     switch (architecture) {
2250                         case 'arm64':
2251                             // Windows only
2252                             if (os != 'Windows_NT' || isBuildOnly) {
2253                                 return
2254                             }
2255                             break
2256                         case 'arm':
2257                             if ((os != 'Ubuntu') && (os != 'Windows_NT')) {
2258                                 return
2259                             }
2260                             break
2261                         case 'x86':
2262                         case 'x86compatjit':
2263                         case 'x86lb':
2264                             // Skip non-windows
2265                             if (os != 'Windows_NT') {
2266                                 return
2267                             }
2268                             break
2269                         case 'x64':
2270                             // Everything implemented
2271                             break
2272                         default:
2273                             println("Unknown architecture: ${architecture}")
2274                             assert false
2275                             break
2276                     }
2277
2278                     // Skip scenarios (blanket skipping for jit stress modes, which are good most everywhere
2279                     // with checked builds
2280                     def enableCorefxTesting = false
2281                     if (Constants.jitStressModeScenarios.containsKey(scenario)) {
2282                         if (configuration != 'Checked') {
2283                             return
2284                         }
2285
2286                         enableCorefxTesting = isCorefxTesting(scenario)
2287
2288                         // Since these are just execution time differences,
2289                         // skip platforms that don't execute the tests here (Windows_NT only)
2290                         def isEnabledOS = (os == 'Windows_NT') || (os == 'Ubuntu' && enableCorefxTesting)
2291                         if (!isEnabledOS || isBuildOnly) {
2292                             return
2293                         }
2294
2295                         switch (architecture) {
2296                             case 'arm64':
2297                                 if ((scenario != 'gcstress0x3') && (scenario != 'gcstress0xc')) {
2298                                     return
2299                                 }
2300                                 break
2301                             case 'x64':
2302                             case 'x86':
2303                                 // Everything implemented
2304                                 break
2305                             case 'x86compatjit':
2306                             case 'x86lb':
2307                                 // No stress modes for compatjit.dll, legacyjit.dll.
2308                                 // (There's no technical reason we couldn't allow these.)
2309                                 return
2310                             default:
2311                                 return
2312                         }
2313                     }
2314                     else {
2315                         // If this is a r2r jitstress, jitstressregs, jitminopts, or forcerelocs scenario
2316                         // and configuration is not Checked, bail out.
2317                         if (configuration != 'Checked' && Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
2318                             return;
2319                         }
2320
2321                         // Skip scenarios
2322                         switch (scenario) {
2323                             case 'pri1':
2324                                 // The pri1 build isn't necessary except for Windows_NT.  Non-Windows NT uses
2325                                 // the default scenario build
2326                                 if (os != 'Windows_NT') {
2327                                     return
2328                                 }
2329                                 // Only x64 for now
2330                                 if (architecture != 'x64') {
2331                                     return
2332                                 }
2333                                 break
2334                             case 'ilrt':
2335                                 // The ilrt build isn't necessary except for Windows_NT.  Non-Windows NT uses
2336                                 // the default scenario build
2337                                 if (os != 'Windows_NT') {
2338                                     return
2339                                 }
2340                                 // Only x64 for now
2341                                 if (architecture != 'x64') {
2342                                     return
2343                                 }
2344                                 // Release only
2345                                 if (configuration != 'Release') {
2346                                     return
2347                                 }
2348                                 break
2349                             case 'jitdiff':
2350                                 if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX') {
2351                                     return
2352                                 }
2353                                 if (architecture != 'x64') {
2354                                     return
2355                                 }
2356                                 if (configuration != 'Checked') {
2357                                     return
2358                                 }
2359                                 break
2360                             case 'r2r':
2361                                 // The r2r build isn't necessary except for Windows_NT.  Non-Windows NT uses
2362                                 // the default scenario build
2363                                 if (os != 'Windows_NT') {
2364                                     return
2365                                 }
2366                                 if (architecture != 'x64') {
2367                                     return
2368                                 }
2369                                 break
2370                             case 'pri1r2r':
2371                                 // The pri1r2r build isn't necessary except for Windows_NT.  Non-Windows NT uses
2372                                 // the default scenario build
2373                                 if (os != 'Windows_NT') {
2374                                     return
2375                                 }
2376                                 if (architecture != 'x64') {
2377                                     if (architecture != 'arm64' || configuration == 'Debug') {
2378                                         return
2379                                     }
2380                                 }
2381                                 break
2382                             case 'gcstress15_pri1r2r':
2383                             case 'r2r_jitstress1':
2384                             case 'r2r_jitstress2':
2385                             case 'r2r_jitstressregs1':
2386                             case 'r2r_jitstressregs2':
2387                             case 'r2r_jitstressregs3':
2388                             case 'r2r_jitstressregs4':
2389                             case 'r2r_jitstressregs8':
2390                             case 'r2r_jitstressregsx10':
2391                             case 'r2r_jitstressregsx80':
2392                             case 'r2r_jitminopts':
2393                             case 'r2r_jitforcerelocs':
2394                                 // The above builds are not necessary except for Windows_NT.  Non-Windows NT uses
2395                                 // the default scenario build
2396                                 if (os != 'Windows_NT') {
2397                                     return
2398                                 }
2399                                 if (architecture != 'x64') {
2400                                     return
2401                                 }
2402                                 break
2403                             case 'longgc':
2404                             case 'gcsimulator':
2405                                 if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX') {
2406                                     return
2407                                 }
2408                                 if (architecture != 'x64') {
2409                                     return
2410                                 }
2411                                 if (configuration != 'Release') {
2412                                     return
2413                                 }
2414                                 break
2415                             case 'standalone_gc':
2416                                 if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX') {
2417                                     return
2418                                 }
2419
2420                                 if (architecture != 'x64') {
2421                                     return
2422                                 }
2423
2424                                 if (configuration != 'Release' && configuration != 'Checked') {
2425                                     return
2426                                 }
2427                                 break
2428                             // We need Windows x64 Release bits for the code coverage build
2429                             case 'coverage':
2430                                 if (os != 'Windows_NT') {
2431                                     return
2432                                 }
2433                                 if (architecture != 'x64') {
2434                                     return
2435                                 }
2436                                 if (configuration != 'Release') {
2437                                     return
2438                                 }
2439                                 break
2440                             // We only run Windows and Ubuntu x64 Checked for formatting right now
2441                             case 'formatting':
2442                                 if (os != 'Windows_NT' && os != 'Ubuntu') {
2443                                     return
2444                                 }
2445                                 if (architecture != 'x64') {
2446                                     return
2447                                 }
2448                                 if (configuration != 'Checked') {
2449                                     return
2450                                 }
2451                                 if (isBuildOnly) {
2452                                     return
2453                                 }
2454                                 break
2455                             case 'default':
2456                                 // Nothing skipped
2457                                 break
2458                             default:
2459                                 println("Unknown scenario: ${scenario}")
2460                                 assert false
2461                                 break
2462                         }
2463                     }
2464
2465                     // Calculate names
2466                     def lowerConfiguration = configuration.toLowerCase()
2467                     def jobName = getJobName(configuration, architecture, os, scenario, isBuildOnly, isLinuxEmulatorBuild)
2468                     def folderName = isJITStressJob(scenario) ? 'jitstress' : '';
2469
2470                     // Create the new job
2471                     def newJob = job(Utilities.getFullJobName(project, jobName, isPR, folderName)) {}
2472
2473                     setMachineAffinity(newJob, os, architecture)
2474
2475                     // Add all the standard options
2476                     Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
2477                     addTriggers(newJob, branch, isPR, architecture, os, configuration, scenario, false, isBuildOnly, isLinuxEmulatorBuild)
2478
2479                     def buildCommands = calculateBuildCommands(newJob, scenario, branch, isPR, architecture, configuration, os, enableCorefxTesting, isBuildOnly, isLinuxEmulatorBuild)
2480                     def osGroup = getOSGroup(os)
2481
2482                     newJob.with {
2483                         steps {
2484                             if (os == 'Windows_NT') {
2485                                 buildCommands.each { buildCommand ->
2486                                     batchFile(buildCommand)
2487                                 }
2488                             }
2489                             else {
2490                                 // Setup corefx and Windows test binaries for Linux ARM Emulator Build
2491                                 if (isLinuxEmulatorBuild) {
2492                                     // Define the Windows Tests and Corefx build job names
2493                                     def WindowTestsName = projectFolder + '/' +
2494                                                           Utilities.getFullJobName(project,
2495                                                                                    getJobName(lowerConfiguration,
2496                                                                                               'x64' ,
2497                                                                                               'windows_nt',
2498                                                                                               'default',
2499                                                                                               true),
2500                                                                                    false)
2501                                     def corefxFolder = Utilities.getFolderName('dotnet/corefx') + '/' +
2502                                                        Utilities.getFolderName(branch)
2503
2504                                     // Copy the Windows test binaries and the Corefx build binaries
2505                                     copyArtifacts(WindowTestsName) {
2506                                         excludePatterns('**/testResults.xml', '**/*.ni.dll')
2507                                         buildSelector {
2508                                             latestSuccessful(true)
2509                                         }
2510                                     }
2511                                     copyArtifacts("${corefxFolder}/tizen_armel_cross_${lowerConfiguration}") {
2512                                         includePatterns('bin/build.tar.gz')
2513                                         buildSelector {
2514                                             latestSuccessful(true)
2515                                         }
2516                                     }
2517                                 }
2518
2519                                 buildCommands.each { buildCommand ->
2520                                     shell(buildCommand)
2521                                 }
2522                             }
2523                         }
2524                     } // newJob.with
2525
2526                 } // os
2527             } // configuration
2528         } // architecture
2529     } // isPR
2530 } // scenario
2531
2532
2533 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
2534 combinedScenarios.each { scenario ->
2535     [true, false].each { isPR ->
2536         // Architectures.  x64 only at this point
2537         ['x64'].each { architecture ->
2538             // Put the OS's supported for coreclr cross testing here
2539             Constants.crossList.each { os ->
2540                 Constants.configurationList.each { configuration ->
2541
2542                     if (Constants.jitStressModeScenarios.containsKey(scenario)) {
2543                         if (configuration != 'Checked') {
2544                             return
2545                         }
2546                         if (isCorefxTesting(scenario)) {
2547                             return
2548                         }
2549                         //Skip stress modes for these scenarios
2550                         if (os == 'RHEL7.2' || os == 'Debian8.4') {
2551                             return
2552                         }
2553                     }
2554                     // If this is a r2r jitstress, jitstressregs, jitminopts or forcerelocs scenario
2555                     // and configuration is not Checked, bail out.
2556                     else if (configuration != 'Checked' && Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
2557                         return;
2558                     }
2559                     // For CentOS, we only want Checked/Release pri1 builds.
2560                     else if (os == 'CentOS7.1') {
2561                         if (scenario != 'pri1' &&
2562                             scenario != 'r2r' &&
2563                             scenario != 'pri1r2r' &&
2564                             scenario != 'gcstress15_pri1r2r' &&
2565                             Constants.r2rJitStressScenarios.indexOf(scenario) == -1) {
2566                             return
2567                         }
2568                         if (configuration != 'Checked' && configuration != 'Release') {
2569                             return
2570                         }
2571                     }
2572                     // For RedHat and Debian, we only do Release pri1 builds.
2573                     else if (os == 'RHEL7.2' || os == 'Debian8.4') {
2574                         if (scenario != 'pri1') {
2575                             return
2576                         }
2577                         if (configuration != 'Release') {
2578                             return
2579                         }
2580                     }
2581                     else {
2582                         // Skip scenarios
2583                         switch (scenario) {
2584                             case 'pri1':
2585                                 // Nothing skipped
2586                                 break
2587                             case 'ilrt':
2588                                 // Release only
2589                                 if (configuration != 'Release') {
2590                                     return
2591                                 }
2592                                 break
2593                             case 'jitdiff':
2594                                 if (configuration != 'Checked') {
2595                                     return;
2596                                 }
2597                             case 'r2r':
2598                                 //Skip configs that aren't Checked or Release (so just Debug, for now)
2599                                 if (configuration != 'Checked' && configuration != 'Release') {
2600                                     return
2601                                 }
2602                                 break
2603                             case 'pri1r2r':
2604                                 //Skip configs that aren't Checked or Release (so just Debug, for now)
2605                                 if (configuration != 'Checked' && configuration != 'Release') {
2606                                     return
2607                                 }
2608                                 break
2609                             case 'gcstress15_pri1r2r':
2610                             case 'r2r_jitstress1':
2611                             case 'r2r_jitstress2':
2612                             case 'r2r_jitstressregs1':
2613                             case 'r2r_jitstressregs2':
2614                             case 'r2r_jitstressregs3':
2615                             case 'r2r_jitstressregs4':
2616                             case 'r2r_jitstressregs8':
2617                             case 'r2r_jitstressregsx10':
2618                             case 'r2r_jitstressregsx80':
2619                             case 'r2r_jitminopts':
2620                             case 'r2r_jitforcerelocs':
2621                                 //Skip configs that aren't Checked or Release (so just Debug, for now)
2622                                 if (configuration != 'Checked' && configuration != 'Release') {
2623                                     return
2624                                 }
2625                                 break
2626                             case 'longgc':
2627                             case 'gcsimulator':
2628                                 // Long GC tests take a long time on non-Release builds
2629                                 if (configuration != 'Release') {
2630                                     return
2631                                 }
2632                                 break
2633                             case 'standalone_gc':
2634                                 if (configuration != 'Release' && configuration != 'Checked') {
2635                                     return
2636                                 }
2637                             case 'coverage':
2638                                 //We only want Ubuntu Release for coverage
2639                                 if (os != 'Ubuntu') {
2640                                     return
2641                                 }
2642                                 if (configuration != 'Release') {
2643                                     return
2644                                 }
2645                             case 'formatting':
2646                                 return
2647                             case 'default':
2648                                 // Nothing skipped
2649                                 break
2650                             default:
2651                                 println("Unknown scenario: ${scenario}")
2652                                 assert false
2653                                 break
2654                         }
2655                     }
2656
2657                     def lowerConfiguration = configuration.toLowerCase()
2658                     def osGroup = getOSGroup(os)
2659                     def jobName = getJobName(configuration, architecture, os, scenario, false) + "_tst"
2660
2661                     // Unless this is a coverage test run, we want to copy over the default build of coreclr.
2662                     def inputScenario = 'default'
2663                     if (scenario == 'coverage') {
2664                         inputScenario = 'coverage'
2665                     }
2666                     def inputCoreCLRBuildName = projectFolder + '/' +
2667                         Utilities.getFullJobName(project, getJobName(configuration, architecture, os, inputScenario, false), isPR)
2668                     // If this is a stress scenario, there isn't any difference in the build job
2669                     // so we didn't create a build only job for windows_nt specific to that stress mode.  Just copy
2670                     // from the default scenario
2671                     def testBuildScenario = scenario
2672                     if (testBuildScenario == 'coverage' || testBuildScenario == 'pri1r2r'|| testBuildScenario == 'gcstress15_pri1r2r') {
2673                         testBuildScenario = 'pri1'
2674                     }
2675                     else if ( testBuildScenario == 'r2r' || isLongGc(testBuildScenario)) {
2676                         testBuildScenario = 'default'
2677                     }
2678                     def inputWindowTestsBuildName = ''
2679                     if (Constants.jitStressModeScenarios.containsKey(testBuildScenario)) {
2680                         inputWindowTestsBuildName = projectFolder + '/' +
2681                             Utilities.getFullJobName(project, getJobName(configuration, architecture, 'windows_nt', 'default', true), isPR)
2682                     }
2683                     else {
2684                         inputWindowTestsBuildName = projectFolder + '/' +
2685                             Utilities.getFullJobName(project, getJobName(configuration, architecture, 'windows_nt', testBuildScenario, true), isPR)
2686                     }
2687                     // Enable Server GC for Ubuntu PR builds
2688                     def serverGCString = ''
2689
2690                     // Whether or not this test run should be run sequentially instead
2691                     // of in parallel. Only used for long GC tests.
2692                     def sequentialString = ''
2693
2694                     // Whether or not this test run should run a specific playlist.
2695                     // Only used for long GC tests.
2696
2697                     // A note - runtest.sh does have "--long-gc" and "--gcsimulator" options
2698                     // for running long GC and GCSimulator tests, respectively. We don't use them
2699                     // here because using a playlist file produces much more readable output on the CI machines
2700                     // and reduces running time.
2701                     def playlistString = ''
2702
2703                     if (os == 'Ubuntu' && isPR){
2704                         serverGCString = '--useServerGC'
2705                     }
2706
2707                     // pass --crossgen to runtest.sh for crossgen builds
2708                     def crossgenStr = ''
2709                     def runcrossgentestsStr = ''
2710                     def runjitstressStr = ''
2711                     def runjitstressregsStr = ''
2712                     def runjitmioptsStr = ''
2713                     def runjitforcerelocsStr = ''
2714                     def runjitdisasmStr = ''
2715                     def gcstressStr = ''
2716
2717                     if (scenario == 'r2r' ||
2718                         scenario == 'pri1r2r' ||
2719                         scenario == 'gcstress15_pri1r2r' ||
2720                         Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
2721                             crossgenStr = '--crossgen'
2722                             runcrossgentestsStr = '--runcrossgentests'
2723
2724                             if (scenario == 'r2r_jitstress1'){
2725                                 runjitstressStr = '--jitstress=1'
2726                             }
2727                             else if (scenario == 'r2r_jitstress2') {
2728                                 runjitstressStr = '--jitstress=2'
2729                             }
2730                             else if (scenario == 'r2r_jitstressregs1'){
2731                                 runjitstressregsStr = '--jitstressregs=1'
2732                             }
2733                             else if (scenario == 'r2r_jitstressregs2') {
2734                                 runjitstressregsStr = '--jitstressregs=2'
2735                             }
2736                             else if (scenario == 'r2r_jitstressregs3') {
2737                                 runjitstressregsStr = '--jitstressregs=3'
2738                             }
2739                             else if (scenario == 'r2r_jitstressregs4') {
2740                                 runjitstressregsStr = '--jitstressregs=4'
2741                             }
2742                             else if (scenario == 'r2r_jitstressregs8') {
2743                                 runjitstressregsStr = '--jitstressregs=8'
2744                             }
2745                             else if (scenario == 'r2r_jitstressregsx10') {
2746                                 runjitstressregsStr = '--jitstressregs=x10'
2747                             }
2748                             else if (scenario == 'r2r_jitstressregsx80') {
2749                                 runjitstressregsStr = '--jitstressregs=x80'
2750                             }
2751                             else if (scenario == 'r2r_jitminopts') {
2752                                 runjitmioptsStr = '--jitminopts'
2753                             }
2754                             else if (scenario == 'r2r_jitforcerelocs') {
2755                                 runjitforcerelocsStr = '--jitforcerelocs'
2756                             }
2757                     }
2758                     if  (scenario == 'gcstress15_pri1r2r')
2759                     {
2760                         gcstressStr = '--gcstresslevel=0xF'
2761                     }
2762
2763                     if (scenario == 'jitdiff')
2764                     {
2765                         runjitdisasmStr = '--jitdisasm --crossgen'
2766                     }
2767
2768                     if (isLongGc(scenario)) {
2769                         // Long GC tests behave very poorly when they are not
2770                         // the only test running (many of them allocate until OOM).
2771                         sequentialString = '--sequential'
2772
2773                         // The Long GC playlist contains all of the tests that are
2774                         // going to be run. The GCSimulator playlist contains all of
2775                         // the GC simulator tests.
2776                         if (scenario == 'longgc') {
2777                             playlistString = '--long-gc --playlist=./tests/longRunningGcTests.txt'
2778                         }
2779                         else if (scenario == 'gcsimulator') {
2780                             playlistString = '--gcsimulator --playlist=./tests/gcSimulatorTests.txt'
2781                         }
2782                     }
2783
2784                     def folder = isJITStressJob(scenario) ? 'jitstress' : ''
2785                     def newJob = job(Utilities.getFullJobName(project, jobName, isPR, folder)) {
2786                         // Add parameters for the inputs
2787
2788                         parameters {
2789                             stringParam('CORECLR_WINDOWS_BUILD', '', 'Build number to copy CoreCLR windows test binaries from')
2790                             stringParam('CORECLR_BUILD', '', "Build number to copy CoreCLR ${osGroup} binaries from")
2791                         }
2792
2793                         steps {
2794                             // Set up the copies
2795
2796                             // Coreclr build containing the tests and mscorlib
2797
2798                             copyArtifacts(inputWindowTestsBuildName) {
2799                                 excludePatterns('**/testResults.xml', '**/*.ni.dll')
2800                                 buildSelector {
2801                                     buildNumber('${CORECLR_WINDOWS_BUILD}')
2802                                 }
2803                             }
2804
2805                             if (scenario == 'coverage') {
2806
2807                                 // Move coreclr to clr directory
2808                                 shell("rm -rf .clr; mkdir .clr; mv * .clr; mv .git .clr; mv .clr clr")
2809
2810                                 // Build coreclr
2811                                 shell("./clr/build.sh coverage verbose ${lowerConfiguration} ${architecture}")
2812
2813                                 // Remove folders from obj that we don't expect to be covered. May update this later.
2814                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/ToolBox")
2815                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/debug")
2816                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/ilasm")
2817                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/ildasm")
2818                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/dlls/dbgshim")
2819                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/dlls/mscordac")
2820                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/dlls/mscordbi")
2821
2822                                 // Run PAL tests
2823                                 shell("./clr/src/pal/tests/palsuite/runpaltests.sh \$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration} \$(pwd)/clr/bin/paltestout")
2824
2825                                 // Remove obj files for PAL tests so they're not included in coverage results
2826                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/pal/tests")
2827
2828                                 // Unzip the tests first.  Exit with 0
2829                                 shell("unzip -q -o ./clr/bin/tests/tests.zip -d ./clr/bin/tests/Windows_NT.${architecture}.${configuration} || exit 0")
2830
2831                                 // Get corefx
2832                                 shell("git clone https://github.com/dotnet/corefx fx")
2833
2834                                 // Build Linux corefx
2835                                 shell("./fx/build-native.sh -release -buildArch=x64 -os=Linux")
2836                                 shell("./fx/build-managed.sh -release -buildArch=x64 -osgroup=Linux -skiptests")
2837
2838                                 def testEnvOpt = ""
2839                                 def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
2840                                 def createScriptCmds = genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios['heapverify1'], scriptFileName)
2841                                 shell("${createScriptCmds}")
2842                                 testEnvOpt = "--test-env=" + scriptFileName
2843
2844                                 // Run corefx tests
2845                                 shell("""./fx/run-test.sh \\
2846                 --coreclr-bins \$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration} \\
2847                 --mscorlib-bins \$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration} \\
2848                 --corefx-tests \$(pwd)/fx/bin/tests/${osGroup}.AnyCPU.${configuration} \\
2849                 --corefx-native-bins \$(pwd)/fx/bin/${osGroup}.${architecture}.${configuration} \\
2850                 --configurationGroup Release""")
2851
2852
2853                                 // Run coreclr tests w/ workstation GC
2854                                 shell("""./clr/tests/runtest.sh \\
2855                 --testRootDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2856                 --testNativeBinDir=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2857                 --coreClrBinDir=\"\$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2858                 --mscorlibDir=\"\$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2859                 --coreFxBinDir=\"\$(pwd)/fx/bin/runtime/netcoreapp-${osGroup}-Release-${architecture}\" \\
2860                 --crossgen --runcrossgentests""")
2861
2862                                 // Run coreclr tests w/ server GC & HeapVerify enabled
2863                                 shell("""./clr/tests/runtest.sh \\
2864                 --testRootDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2865                 --testNativeBinDir=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2866                 --coreOverlayDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}/Tests/coreoverlay\" \\
2867                 --useServerGC ${testEnvOpt}""")
2868
2869                                  // Run long-running coreclr GC tests & produce coverage reports
2870                                 shell("""./clr/tests/runtest.sh \\
2871                 --testRootDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2872                 --testNativeBinDir=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2873                 --coreOverlayDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}/Tests/coreoverlay\" \\
2874                 --long-gc --playlist=\"\$(pwd)/clr/tests/longRunningGcTests.txt\" --coreclr-coverage\\
2875                 --coreclr-objs=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}\" \\
2876                 --coreclr-src=\"\$(pwd)/clr/src\" \\
2877                 --coverage-output-dir=\"\${WORKSPACE}/coverage\" """)
2878
2879                             }
2880                             else {
2881
2882                                 // Coreclr build we are trying to test
2883
2884                                 copyArtifacts(inputCoreCLRBuildName) {
2885                                     excludePatterns('**/testResults.xml', '**/*.ni.dll')
2886                                     buildSelector {
2887                                         buildNumber('${CORECLR_BUILD}')
2888                                     }
2889                                 }
2890
2891                                 def corefxFolder = Utilities.getFolderName('dotnet/corefx') + '/' + Utilities.getFolderName(branch)
2892
2893                                 // Corefx components.  We now have full stack builds on all distros we test here, so we can copy straight from CoreFX jobs.
2894                                 def osJobName = (os == 'Ubuntu') ? 'ubuntu14.04' : os.toLowerCase()
2895                                 copyArtifacts("${corefxFolder}/${osJobName}_release") {
2896                                     includePatterns('bin/build.tar.gz')
2897                                     buildSelector {
2898                                         latestSuccessful(true)
2899                                     }
2900                                 }
2901
2902                                 shell ("mkdir ./bin/CoreFxBinDir")
2903                                 // Unpack the corefx binaries
2904                                 shell("tar -xf ./bin/build.tar.gz -C ./bin/CoreFxBinDir")
2905
2906                                 // Unzip the tests first.  Exit with 0
2907                                 shell("unzip -q -o ./bin/tests/tests.zip -d ./bin/tests/Windows_NT.${architecture}.${configuration} || exit 0")
2908
2909                                 // Execute the tests
2910                                 // If we are running a stress mode, we'll set those variables first
2911                                 def testEnvOpt = ""
2912                                 if (Constants.jitStressModeScenarios.containsKey(scenario)) {
2913                                     def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
2914                                     def createScriptCmds = genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios[scenario], scriptFileName)
2915                                     shell("${createScriptCmds}")
2916                                     testEnvOpt = "--test-env=" + scriptFileName
2917                                 }
2918
2919                                 if (isGCStressRelatedTesting(scenario)) {
2920                                     shell('./init-tools.sh')
2921                                 }
2922
2923                                 shell("""./tests/runtest.sh \\
2924                 --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2925                 --testNativeBinDir=\"\${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2926                 --coreClrBinDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2927                 --mscorlibDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2928                 --coreFxBinDir=\"\${WORKSPACE}/bin/CoreFxBinDir\" \\
2929                 --limitedDumpGeneration \\
2930                 ${testEnvOpt} ${serverGCString} ${gcstressStr} ${crossgenStr} ${runcrossgentestsStr} ${runjitstressStr} ${runjitstressregsStr} ${runjitmioptsStr} ${runjitforcerelocsStr} ${runjitdisasmStr} ${sequentialString} ${playlistString}""")
2931                             }
2932                         }
2933                     }
2934
2935                     if (scenario == 'coverage') {
2936                         // Publish coverage reports
2937                         Utilities.addHtmlPublisher(newJob, '${WORKSPACE}/coverage/Coverage/reports', 'Code Coverage Report', 'coreclr.html')
2938                         // TODO: Add once external email sending is available again
2939                         // addEmailPublisher(newJob, 'clrcoverage@microsoft.com')
2940                     }
2941
2942                     if (scenario == 'jitdiff') {
2943                         Utilities.addArchival(newJob, "bin/tests/${osGroup}.${architecture}.${configuration}/dasm/**")
2944                     }
2945
2946                     // Experimental: If on Ubuntu 14.04, then attempt to pull in crash dump links
2947                     if (os in ['Ubuntu']) {
2948                         SummaryBuilder summaries = new SummaryBuilder()
2949                         summaries.addLinksSummaryFromFile('Crash dumps from this run:', 'dumplings.txt')
2950                         summaries.emit(newJob)
2951                     }
2952
2953                     setMachineAffinity(newJob, os, architecture)
2954                     Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
2955                     // Set timeouts to 240.
2956                     setTestJobTimeOut(newJob, scenario)
2957                     Utilities.addXUnitDotNETResults(newJob, '**/coreclrtests.xml')
2958
2959                     // Create a build flow to join together the build and tests required to run this
2960                     // test.
2961                     // Windows CoreCLR build and Linux CoreCLR build (in parallel) ->
2962                     // Linux CoreCLR test
2963                     def flowJobName = getJobName(configuration, architecture, os, scenario, false) + "_flow"
2964                     def fullTestJobName = projectFolder + '/' + newJob.name
2965                     // Add a reference to the input jobs for report purposes
2966                     JobReport.Report.addReference(inputCoreCLRBuildName)
2967                     JobReport.Report.addReference(inputWindowTestsBuildName)
2968                     JobReport.Report.addReference(fullTestJobName)
2969                     def newFlowJob;
2970
2971                     // If this is a coverage job, we don't copy any input coreCLR build - instead, we build it as part of the flow job,
2972                     // so that coverage data can be preserved.
2973                     if (scenario == 'coverage') {
2974                         newFlowJob = buildFlowJob(Utilities.getFullJobName(project, flowJobName, isPR, folder)) {
2975                         buildFlow("""
2976 // Build the input Windows job
2977 windowsBuildJob = build(params, '${inputWindowTestsBuildName}')
2978
2979 // And then build the test build
2980 build(params + [CORECLR_WINDOWS_BUILD: windowsBuildJob.build.number], '${fullTestJobName}')
2981 """)
2982                         }
2983                     // Normal jobs copy a Windows build & a non-Windows build
2984                     } else {
2985                         newFlowJob = buildFlowJob(Utilities.getFullJobName(project, flowJobName, isPR, folder)) {
2986                         buildFlow("""
2987 // Build the input jobs in parallel
2988 parallel (
2989     { coreclrBuildJob = build(params, '${inputCoreCLRBuildName}') },
2990     { windowsBuildJob = build(params, '${inputWindowTestsBuildName}') }
2991 )
2992
2993 // And then build the test build
2994 build(params + [CORECLR_BUILD: coreclrBuildJob.build.number,
2995                 CORECLR_WINDOWS_BUILD: windowsBuildJob.build.number], '${fullTestJobName}')
2996 """)
2997                         }
2998                     }
2999
3000                     setMachineAffinity(newFlowJob, os, architecture)
3001                     Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
3002                     addTriggers(newFlowJob, branch, isPR, architecture, os, configuration, scenario, true, false, false)
3003                 } // configuration
3004             } // os
3005         } // architecture
3006     } // isPR
3007 } // scenario
3008
3009 JobReport.Report.generateJobReport(out)
3010
3011 // Make the call to generate the help job
3012 Utilities.createHelperJob(this, project, branch,
3013     "Welcome to the ${project} Repository",  // This is prepended to the help message
3014     "Have a nice day!")  // This is appended to the help message.  You might put known issues here.