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