72a8c1bc4dec43ef39b70e2b06acb4ef5d456ee1
[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 fxRoot = "%WORKSPACE%\\_\\fx"
1900                                 buildCommands += "python %WORKSPACE%\\tests\\scripts\\run-corefx-tests.py -arch ${arch} -build_type ${configuration} -fx_root ${fxRoot} -fx_branch ${branch} -env_script ${stepScriptLocation}"
1901
1902                                 // Archive only result xml files since corefx/bin/tests is very large around 10 GB.
1903                                 // For windows, pull full test results and test drops for x86/x64
1904                                 Utilities.addArchival(newJob, "${fxRoot}/bin/tests/**/testResults.xml")
1905
1906                                 // Set timeout
1907                                 setTestJobTimeOut(newJob, scenario)
1908
1909                                 if (architecture == 'x64' || !isPR) {
1910                                     Utilities.addXUnitDotNETResults(newJob, "${fxRoot}/bin/tests/**/testResults.xml")
1911                                 }
1912                             }
1913                             else {
1914                                 buildCommands += "%WORKSPACE%\\tests\\runtest.cmd ${runtestArguments} TestEnv ${stepScriptLocation}"
1915                             }
1916                         }
1917                         else if (architecture == 'x64' || architecture == 'x86') {
1918                             buildCommands += "tests\\runtest.cmd ${runtestArguments}"
1919                         }                                        
1920                         else if (architecture == 'x86compatjit') {
1921                             def testEnvLocation = "%WORKSPACE%\\tests\\x86\\compatjit_x86_testenv.cmd"
1922                             buildCommands += "tests\\runtest.cmd ${runtestArguments} Exclude0 x86_legacy_backend_issues.targets TestEnv ${testEnvLocation}"
1923                         }
1924                         else if (architecture == 'x86lb') {
1925                             def testEnvLocation = "%WORKSPACE%\\tests\\x86\\legacyjit_x86_testenv.cmd"
1926                             buildCommands += "tests\\runtest.cmd ${runtestArguments} Exclude0 x86_legacy_backend_issues.targets TestEnv ${testEnvLocation}"
1927                         }
1928                     }
1929
1930                     if (!enableCorefxTesting) {
1931                         // Run the rest of the build    
1932                         // Build the mscorlib for the other OS's
1933                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} linuxmscorlib"
1934                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} freebsdmscorlib"
1935                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} osxmscorlib"
1936
1937                         // Zip up the tests directory so that we don't use so much space/time copying
1938                         // 10s of thousands of files around.
1939                         buildCommands += "powershell -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${arch}.${configuration}', '.\\bin\\tests\\tests.zip')\"";
1940
1941                         if (!Constants.jitStressModeScenarios.containsKey(scenario) && scenario != 'jitdiff') {
1942                             // For windows, pull full test results and test drops for x86/x64.
1943                             // No need to pull for stress mode scenarios (downstream builds use the default scenario)
1944                             Utilities.addArchival(newJob, "bin/Product/**,bin/tests/tests.zip")
1945                         }
1946
1947                         if (scenario == 'jitdiff') {
1948                             // retrive jit-dasm output for base commit, and run jit-diff
1949                             if (!isBuildOnly) {
1950                                 // if this is a build only job, we want to keep the default (build) artifacts for the flow job
1951                                 Utilities.addArchival(newJob, "bin/tests/${osGroup}.${arch}.${configuration}/dasm/**")
1952                             }
1953                         }
1954                         
1955                         if (!isBuildOnly) {
1956                             if (architecture == 'x64' || !isPR) {
1957                                 Utilities.addXUnitDotNETResults(newJob, 'bin/**/TestRun*.xml')
1958                             }
1959                             setTestJobTimeOut(newJob, scenario)
1960                         }
1961                     }
1962                     break
1963                 case 'arm':
1964                     assert (scenario == 'default')
1965                     
1966                     // Set time out
1967                     setTestJobTimeOut(newJob, scenario)
1968
1969                     if ( lowerConfiguration == "debug" ) {
1970                         // For Debug builds, we will do a P1 test build
1971                         buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} -priority=1"
1972                     }
1973                     else {
1974                         buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture}"
1975                     }
1976                     // Add archival.
1977                     Utilities.addArchival(newJob, "bin/Product/**")
1978                     break
1979                 case 'arm64':
1980                     assert (scenario == 'default') || (scenario == 'pri1r2r') || (scenario == 'gcstress0x3') || (scenario == 'gcstress0xc')
1981                     // Set time out
1982                     setTestJobTimeOut(newJob, scenario)
1983
1984                     // Debug runs take too long to run. So build job only.
1985                     if (lowerConfiguration == "debug") {
1986                        buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} toolset_dir C:\\ats2"
1987                     }
1988                     else {
1989                        buildCommands += "set __TestIntermediateDir=int&&build.cmd skiptests ${lowerConfiguration} ${architecture} toolset_dir C:\\ats2"
1990                        // Test build and run are launched together.
1991                        buildCommands += "python tests\\scripts\\arm64_post_build.py -repo_root %WORKSPACE% -arch ${architecture} -build_type ${lowerConfiguration} -scenario ${scenario} -key_location C:\\tools\\key.txt"
1992                        //Utilities.addXUnitDotNETResults(newJob, 'bin/tests/testResults.xml')
1993                     }
1994
1995                     // Add archival.
1996                     Utilities.addArchival(newJob, "bin/Product/**")
1997                     break
1998                 default:
1999                     println("Unknown architecture: ${architecture}");
2000                     assert false
2001                     break
2002             }
2003             break
2004         // editor brace matching: }
2005         case 'Ubuntu':
2006         case 'Ubuntu16.04':
2007         case 'Ubuntu16.10':
2008         case 'Debian8.4':
2009         case 'OSX':
2010         case 'FreeBSD':
2011         case 'CentOS7.1':
2012         case 'RHEL7.2':
2013         case 'OpenSUSE13.2':
2014         case 'OpenSUSE42.1':
2015         case 'Fedora23': // editor brace matching: {
2016             switch (architecture) {
2017                 case 'x64':
2018                 case 'x86':
2019                 case 'x86compatjit':
2020                 case 'x86lb':
2021                     def arch = architecture
2022                     if (architecture == 'x86compatjit' || architecture == 'x86lb') {
2023                         arch = 'x86'
2024                     }
2025
2026                     if (scenario == 'formatting') {
2027                         buildCommands += "python tests/scripts/format.py -c \${WORKSPACE} -o Linux -a ${arch}"
2028                         Utilities.addArchival(newJob, "format.patch", "", true, false)
2029                         break
2030                     }
2031                 
2032                     if (!enableCorefxTesting) {
2033                         // We run pal tests on all OS but generate mscorlib (and thus, nuget packages)
2034                         // only on supported OS platforms.
2035                         if ((os == 'FreeBSD') || (os == 'OpenSUSE13.2'))
2036                         {
2037                             buildCommands += "./build.sh skipmscorlib verbose ${lowerConfiguration} ${arch}"
2038                         }
2039                         else
2040                         {
2041                             def bootstrapRid = Utilities.getBoostrapPublishRid(os)
2042                             def bootstrapRidEnv = bootstrapRid != null ? "__PUBLISH_RID=${bootstrapRid} " : ''
2043                             buildCommands += "${bootstrapRidEnv}./build.sh verbose ${lowerConfiguration} ${arch}"
2044                         }
2045                         buildCommands += "src/pal/tests/palsuite/runpaltests.sh \${WORKSPACE}/bin/obj/${osGroup}.${arch}.${configuration} \${WORKSPACE}/bin/paltestout"
2046                     
2047                         // Set time out
2048                         setTestJobTimeOut(newJob, scenario)
2049                         // Basic archiving of the build
2050                         Utilities.addArchival(newJob, "bin/Product/**,bin/obj/*/tests/**/*.dylib,bin/obj/*/tests/**/*.so")
2051                         // And pal tests
2052                         Utilities.addXUnitDotNETResults(newJob, '**/pal_tests.xml')
2053                     }
2054                     else {
2055                         // Corefx stress testing                                        
2056                         assert os == 'Ubuntu'
2057                         assert architecture == 'x64'
2058                         assert lowerConfiguration == 'checked'
2059                         assert Constants.jitStressModeScenarios.containsKey(scenario)
2060                         
2061                         // Build coreclr
2062                         buildCommands += "./build.sh verbose ${lowerConfiguration} ${architecture}"
2063                         
2064                         def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
2065                         buildCommands += genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios[scenario], scriptFileName)
2066
2067                         // Build and text corefx
2068                         def fxRoot = "\$WORKSPACE/_/fx"
2069                         buildCommands += "python \$WORKSPACE/tests/scripts/run-corefx-tests.py -arch ${arch} -build_type ${configuration} -fx_root ${fxRoot} -fx_branch ${branch} -env_script ${scriptFileName}"
2070
2071                         // Archive and process test result
2072                         Utilities.addArchival(newJob, "${fxRoot}/bin/tests/**/testResults.xml")
2073                         setTestJobTimeOut(newJob, scenario)
2074                         Utilities.addXUnitDotNETResults(newJob, "${fxRoot}/bin/tests/**/testResults.xml")
2075                     }
2076                     break
2077                 case 'arm64':
2078                     // We don't run the cross build except on Ubuntu
2079                     assert os == 'Ubuntu'
2080                     
2081                     buildCommands += """echo \"Using rootfs in /opt/aarch64-linux-gnu-root\"
2082                         ROOTFS_DIR=/opt/aarch64-linux-gnu-root ./build.sh skipmscorlib arm64 cross verbose ${lowerConfiguration}"""
2083                     
2084                     // Basic archiving of the build, no pal tests
2085                     Utilities.addArchival(newJob, "bin/Product/**")
2086                     break
2087                 case 'arm':
2088                     // All builds for ARM architecture are run on Ubuntu currently
2089                     assert os == 'Ubuntu'
2090                     if (isLinuxEmulatorBuild == false) {
2091                         buildCommands += """echo \"Using rootfs in /opt/arm-liux-genueabihf-root\"
2092                             ROOTFS_DIR=/opt/arm-linux-genueabihf-root ./build.sh skipmscorlib arm cross verbose ${lowerConfiguration}"""
2093                         
2094                         // Basic archiving of the build, no pal tests
2095                         Utilities.addArchival(newJob, "bin/Product/**")
2096                         break
2097                     }
2098                     else {
2099                         // Make sure the build configuration is either of debug or release
2100                         assert ( lowerConfiguration == 'debug' ) || ( lowerConfiguration == 'release' )
2101
2102                         // Setup variables to hold emulator folder path and the rootfs mount path
2103                         def armemul_path = '/opt/linux-arm-emulator'
2104                         def armrootfs_mountpath = '/opt/linux-arm-emulator-root'
2105
2106                         // Unzip the Windows test binaries first. Exit with 0
2107                         buildCommands += "unzip -q -o ./bin/tests/tests.zip -d ./bin/tests/Windows_NT.x64.${configuration} || exit 0"
2108
2109                         // Unpack the corefx binaries
2110                         buildCommands += "tar -xf ./bin/build.tar.gz"
2111
2112                         // Call the ARM emulator build script to cross build and test using the ARM emulator rootfs
2113                         buildCommands += """./tests/scripts/arm32_ci_script.sh \\
2114                         --emulatorPath=${armemul_path} \\
2115                         --mountPath=${armrootfs_mountpath} \\
2116                         --buildConfig=${lowerConfiguration} \\
2117                         --testRootDir=./bin/tests/Windows_NT.x64.${configuration} \\
2118                         --coreFxNativeBinDir=./bin/Linux.arm-softfp.${configuration} \\
2119                         --coreFxBinDir=\"./bin/Linux.AnyCPU.${configuration};./bin/Unix.AnyCPU.${configuration};./bin/AnyOS.AnyCPU.${configuration}\" \\
2120                         --testDirFile=./tests/testsRunningInsideARM.txt"""
2121
2122
2123                         // Basic archiving of the build
2124                         Utilities.addArchival(newJob, "bin/Product/**")
2125                         break
2126                     }
2127                 default:
2128                     println("Unknown architecture: ${architecture}");
2129                     assert false
2130                     break
2131             }
2132             break
2133         // editor brace matching: }
2134         default:
2135             println("Unknown os: ${os}");
2136             assert false
2137             break
2138     } // os
2139
2140     return buildCommands
2141 }
2142
2143 // Additional scenario which can alter behavior
2144
2145 def combinedScenarios = Constants.basicScenarios + Constants.jitStressModeScenarios.keySet()
2146 combinedScenarios.each { scenario ->
2147     [true, false].each { isPR ->
2148         Constants.architectureList.each { architecture ->
2149             Constants.configurationList.each { configuration ->
2150                 Constants.osList.each { os ->
2151                     // If the OS is Windows_NT_BuildOnly, set the isBuildOnly flag to true
2152                     // and reset the os to Windows_NT
2153                     def isBuildOnly = false
2154                     if (os == 'Windows_NT_BuildOnly') {
2155                         isBuildOnly = true
2156                         os = 'Windows_NT'
2157                     }
2158
2159                     // WinArm32 is only built for Debug and Release
2160                     if (os == 'Windows_NT' && architecture == 'arm')
2161                     {
2162                         if (configuration == 'Checked')
2163                         {
2164                             return
2165                         }
2166                     }
2167                     // If the OS is LinuxARMEmulator and arch is arm, set the isLinuxEmulatorBuild
2168                     // flag to true and reset the os to Ubuntu
2169                     // The isLinuxEmulatorBuild flag will be used at a later time to execute the right
2170                     // set of build commands
2171                     // The tuples (LinuxARMEmulator, other architectures) are not handled and control returns
2172                     def isLinuxEmulatorBuild = false
2173                     if (os == 'LinuxARMEmulator' && architecture == 'arm') {
2174                         // Cross Builds only in Debug and Release modes allowed
2175                         if ( configuration == 'Checked' ) {
2176                             return
2177                         }
2178
2179                         isLinuxEmulatorBuild = true
2180                         os = 'Ubuntu'
2181                     } else if (os == 'LinuxARMEmulator') {
2182                         return
2183                     }
2184
2185                     // Skip totally unimplemented (in CI) configurations.
2186                     switch (architecture) {
2187                         case 'arm64':
2188                             // Windows only
2189                             if (os != 'Windows_NT' || isBuildOnly) {
2190                                 return
2191                             }
2192                             break
2193                         case 'arm':
2194                             if ((os != 'Ubuntu') && (os != 'Windows_NT')) {
2195                                 return
2196                             }
2197                             break
2198                         case 'x86':
2199                         case 'x86compatjit':
2200                         case 'x86lb':
2201                             // Skip non-windows
2202                             if (os != 'Windows_NT') {
2203                                 return
2204                             }
2205                             break
2206                         case 'x64':
2207                             // Everything implemented
2208                             break
2209                         default:
2210                             println("Unknown architecture: ${architecture}")
2211                             assert false
2212                             break
2213                     }
2214
2215                     // Skip scenarios (blanket skipping for jit stress modes, which are good most everywhere
2216                     // with checked builds
2217                     def enableCorefxTesting = false
2218                     if (Constants.jitStressModeScenarios.containsKey(scenario)) {
2219                         if (configuration != 'Checked') {
2220                             return
2221                         }
2222                         
2223                         enableCorefxTesting = isCorefxTesting(scenario)
2224                         
2225                         // Since these are just execution time differences,
2226                         // skip platforms that don't execute the tests here (Windows_NT only)
2227                         def isEnabledOS = (os == 'Windows_NT') || (os == 'Ubuntu' && enableCorefxTesting)
2228                         if (!isEnabledOS || isBuildOnly) {
2229                             return
2230                         }
2231                         
2232                         switch (architecture) {
2233                             case 'arm64':
2234                                 if ((scenario != 'gcstress0x3') && (scenario != 'gcstress0xc')) {
2235                                     return
2236                                 }
2237                                 break
2238                             case 'x64':
2239                             case 'x86':
2240                                 // Everything implemented
2241                                 break
2242                             case 'x86compatjit':
2243                             case 'x86lb':
2244                                 // No stress modes for compatjit.dll, legacyjit.dll.
2245                                 // (There's no technical reason we couldn't allow these.)
2246                                 return
2247                             default:
2248                                 return
2249                         }
2250                     }
2251                     else {
2252                         // If this is a r2r jitstress, jitstressregs, jitminopts, or forcerelocs scenario
2253                         // and configuration is not Checked, bail out.
2254                         if (configuration != 'Checked' && Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
2255                             return;
2256                         }
2257
2258                         // Skip scenarios
2259                         switch (scenario) {
2260                             case 'pri1':
2261                                 // The pri1 build isn't necessary except for Windows_NT.  Non-Windows NT uses
2262                                 // the default scenario build
2263                                 if (os != 'Windows_NT') {
2264                                     return
2265                                 }
2266                                 // Only x64 for now
2267                                 if (architecture != 'x64') {
2268                                     return
2269                                 }
2270                                 break
2271                             case 'ilrt':
2272                                 // The ilrt build isn't necessary except for Windows_NT.  Non-Windows NT uses
2273                                 // the default scenario build
2274                                 if (os != 'Windows_NT') {
2275                                     return
2276                                 }
2277                                 // Only x64 for now
2278                                 if (architecture != 'x64') {
2279                                     return
2280                                 }
2281                                 // Release only
2282                                 if (configuration != 'Release') {
2283                                     return
2284                                 }
2285                                 break
2286                             case 'jitdiff':
2287                                 if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX') {
2288                                     return
2289                                 }
2290                                 if (architecture != 'x64') {
2291                                     return
2292                                 }
2293                                 if (configuration != 'Checked') {
2294                                     return
2295                                 }
2296                                 break
2297                             case 'r2r':
2298                                 // The r2r build isn't necessary except for Windows_NT.  Non-Windows NT uses
2299                                 // the default scenario build
2300                                 if (os != 'Windows_NT') {
2301                                     return
2302                                 }
2303                                 if (architecture != 'x64') {
2304                                     return
2305                                 }
2306                                 break
2307                             case 'pri1r2r':
2308                                 // The pri1r2r build isn't necessary except for Windows_NT.  Non-Windows NT uses
2309                                 // the default scenario build
2310                                 if (os != 'Windows_NT') {
2311                                     return
2312                                 }
2313                                 if (architecture != 'x64') {
2314                                     if (architecture != 'arm64' || configuration == 'Debug') {
2315                                         return
2316                                     }
2317                                 }
2318                                 break
2319                             case 'gcstress15_pri1r2r':
2320                             case 'r2r_jitstress1':
2321                             case 'r2r_jitstress2':
2322                             case 'r2r_jitstressregs1':
2323                             case 'r2r_jitstressregs2':
2324                             case 'r2r_jitstressregs3':
2325                             case 'r2r_jitstressregs4':
2326                             case 'r2r_jitstressregs8':
2327                             case 'r2r_jitstressregsx10':
2328                             case 'r2r_jitstressregsx80':
2329                             case 'r2r_jitminopts':
2330                             case 'r2r_jitforcerelocs':
2331                                 // The above builds are not necessary except for Windows_NT.  Non-Windows NT uses
2332                                 // the default scenario build
2333                                 if (os != 'Windows_NT') {
2334                                     return
2335                                 }
2336                                 if (architecture != 'x64') {
2337                                     return
2338                                 }
2339                                 break
2340                             case 'longgc':
2341                             case 'gcsimulator':
2342                                 if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX') {
2343                                     return
2344                                 }
2345                                 if (architecture != 'x64') {
2346                                     return
2347                                 }
2348                                 if (configuration != 'Release') {
2349                                     return
2350                                 }
2351                                 break
2352                             case 'standalone_gc':
2353                                 if (os != 'Windows_NT') {
2354                                     return
2355                                 }
2356
2357                                 if (architecture != 'x64') {
2358                                     return
2359                                 }
2360
2361                                 if (configuration != 'Release' && configuration != 'Checked') {
2362                                     return
2363                                 }
2364                                 break
2365                             // We need Windows x64 Release bits for the code coverage build
2366                             case 'coverage':
2367                                 if (os != 'Windows_NT') {
2368                                     return
2369                                 }
2370                                 if (architecture != 'x64') {
2371                                     return
2372                                 }
2373                                 if (configuration != 'Release') {
2374                                     return
2375                                 }
2376                                 break
2377                             // We only run Windows and Ubuntu x64 Checked for formatting right now
2378                             case 'formatting':
2379                                 if (os != 'Windows_NT' && os != 'Ubuntu') {
2380                                     return
2381                                 }
2382                                 if (architecture != 'x64') {
2383                                     return
2384                                 }
2385                                 if (configuration != 'Checked') {
2386                                     return
2387                                 }
2388                                 if (isBuildOnly) {
2389                                     return
2390                                 }
2391                                 break
2392                             case 'default':
2393                                 // Nothing skipped
2394                                 break
2395                             default:
2396                                 println("Unknown scenario: ${scenario}")
2397                                 assert false
2398                                 break
2399                         }
2400                     }
2401                 
2402                     // Calculate names
2403                     def lowerConfiguration = configuration.toLowerCase()
2404                     def jobName = getJobName(configuration, architecture, os, scenario, isBuildOnly, isLinuxEmulatorBuild)
2405                     def folderName = isJITStressJob(scenario) ? 'jitstress' : '';
2406                     
2407                     // Create the new job
2408                     def newJob = job(Utilities.getFullJobName(project, jobName, isPR, folderName)) {}
2409                     
2410                     setMachineAffinity(newJob, os, architecture)
2411
2412                     // Add all the standard options
2413                     Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
2414                     addTriggers(newJob, branch, isPR, architecture, os, configuration, scenario, false, isBuildOnly, isLinuxEmulatorBuild)
2415                 
2416                     def buildCommands = calculateBuildCommands(newJob, scenario, branch, isPR, architecture, configuration, os, enableCorefxTesting, isBuildOnly, isLinuxEmulatorBuild)
2417                     def osGroup = getOSGroup(os)
2418
2419                     newJob.with {
2420                         steps {
2421                             if (os == 'Windows_NT') {
2422                                 buildCommands.each { buildCommand ->
2423                                     batchFile(buildCommand)
2424                                 }
2425                             }
2426                             else {
2427                                 // Setup corefx and Windows test binaries for Linux ARM Emulator Build
2428                                 if (isLinuxEmulatorBuild) {
2429                                     // Define the Windows Tests and Corefx build job names
2430                                     def WindowTestsName = projectFolder + '/' +
2431                                                           Utilities.getFullJobName(project,
2432                                                                                    getJobName(lowerConfiguration,
2433                                                                                               'x64' ,
2434                                                                                               'windows_nt',
2435                                                                                               'default',
2436                                                                                               true),
2437                                                                                    false)
2438                                     def corefxFolder = Utilities.getFolderName('dotnet/corefx') + '/' +
2439                                                        Utilities.getFolderName(branch)
2440
2441                                     // Copy the Windows test binaries and the Corefx build binaries
2442                                     copyArtifacts(WindowTestsName) {
2443                                         excludePatterns('**/testResults.xml', '**/*.ni.dll')
2444                                         buildSelector {
2445                                             latestSuccessful(true)
2446                                         }
2447                                     }
2448                                     copyArtifacts("${corefxFolder}/linuxarmemulator_softfp_cross_${lowerConfiguration}") {
2449                                         includePatterns('bin/build.tar.gz')
2450                                         buildSelector {
2451                                             latestSuccessful(true)
2452                                         }
2453                                     }
2454                                 }
2455
2456                                 buildCommands.each { buildCommand ->
2457                                     shell(buildCommand)
2458                                 }
2459                             }
2460                         }
2461                     } // newJob.with
2462                     
2463                 } // os
2464             } // configuration
2465         } // architecture
2466     } // isPR
2467 } // scenario
2468
2469
2470 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
2471 combinedScenarios.each { scenario ->
2472     [true, false].each { isPR ->
2473         // Architectures.  x64 only at this point
2474         ['x64'].each { architecture ->
2475             // Put the OS's supported for coreclr cross testing here
2476             Constants.crossList.each { os ->
2477                 Constants.configurationList.each { configuration ->
2478
2479                     if (Constants.jitStressModeScenarios.containsKey(scenario)) {
2480                         if (configuration != 'Checked') {
2481                             return
2482                         }
2483                         if (isCorefxTesting(scenario)) {
2484                             return
2485                         }
2486                         //Skip stress modes for these scenarios
2487                         if (os == 'RHEL7.2' || os == 'Debian8.4' || os == 'OpenSUSE13.2') {
2488                             return
2489                         }
2490                     }
2491                     // If this is a r2r jitstress, jitstressregs, jitminopts or forcerelocs scenario
2492                     // and configuration is not Checked, bail out.
2493                     else if (configuration != 'Checked' && Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
2494                         return;
2495                     }
2496                     // For CentOS, we only want Checked/Release pri1 builds.
2497                     else if (os == 'CentOS7.1') {
2498                         if (scenario != 'pri1' &&
2499                             scenario != 'r2r' && 
2500                             scenario != 'pri1r2r' && 
2501                             scenario != 'gcstress15_pri1r2r' &&
2502                             Constants.r2rJitStressScenarios.indexOf(scenario) == -1) {
2503                             return
2504                         }
2505                         if (configuration != 'Checked' && configuration != 'Release') {
2506                             return
2507                         }
2508                     }
2509                     // For RedHat, Debian, and OpenSUSE, we only do Release pri1 builds.
2510                     else if (os == 'RHEL7.2' || os == 'Debian8.4' || os == 'OpenSUSE13.2') {
2511                         if (scenario != 'pri1') {
2512                             return
2513                         }
2514                         if (configuration != 'Release') {
2515                             return
2516                         }
2517                     }
2518                     else {
2519                         // Skip scenarios
2520                         switch (scenario) {
2521                             case 'pri1':
2522                                 // Nothing skipped
2523                                 break
2524                             case 'ilrt':
2525                                 // Release only
2526                                 if (configuration != 'Release') {
2527                                     return
2528                                 }
2529                                 break
2530                             case 'jitdiff':
2531                                 if (configuration != 'Checked') {
2532                                     return;
2533                                 }
2534                             case 'r2r':
2535                                 //Skip configs that aren't Checked or Release (so just Debug, for now)
2536                                 if (configuration != 'Checked' && configuration != 'Release') {
2537                                     return
2538                                 }
2539                                 break
2540                             case 'pri1r2r':
2541                                 //Skip configs that aren't Checked or Release (so just Debug, for now)
2542                                 if (configuration != 'Checked' && configuration != 'Release') {
2543                                     return
2544                                 }
2545                                 break
2546                             case 'gcstress15_pri1r2r':
2547                             case 'r2r_jitstress1':
2548                             case 'r2r_jitstress2':
2549                             case 'r2r_jitstressregs1':
2550                             case 'r2r_jitstressregs2':
2551                             case 'r2r_jitstressregs3':
2552                             case 'r2r_jitstressregs4':
2553                             case 'r2r_jitstressregs8':
2554                             case 'r2r_jitstressregsx10':
2555                             case 'r2r_jitstressregsx80':
2556                             case 'r2r_jitminopts':
2557                             case 'r2r_jitforcerelocs':
2558                                 //Skip configs that aren't Checked or Release (so just Debug, for now)
2559                                 if (configuration != 'Checked' && configuration != 'Release') {
2560                                     return
2561                                 }
2562                                 break
2563                             case 'longgc':
2564                             case 'gcsimulator':
2565                                 // Long GC tests take a long time on non-Release builds
2566                                 if (configuration != 'Release') {
2567                                     return
2568                                 }
2569                                 break
2570                             case 'standalone_gc':
2571                                 if (configuration != 'Release' && configuration != 'Checked') {
2572                                     return
2573                                 }
2574                             case 'coverage':
2575                                 //We only want Ubuntu Release for coverage
2576                                 if (os != 'Ubuntu') {
2577                                     return
2578                                 }
2579                                 if (configuration != 'Release') {
2580                                     return
2581                                 }
2582                             case 'formatting':
2583                                 return
2584                             case 'default':
2585                                 // Nothing skipped
2586                                 break
2587                             default:
2588                                 println("Unknown scenario: ${scenario}")
2589                                 assert false
2590                                 break
2591                         }
2592                     }
2593                     
2594                     def lowerConfiguration = configuration.toLowerCase()
2595                     def osGroup = getOSGroup(os)
2596                     def jobName = getJobName(configuration, architecture, os, scenario, false) + "_tst"
2597                     
2598                     // Unless this is a coverage test run, we want to copy over the default build of coreclr.
2599                     def inputScenario = 'default'
2600                     if (scenario == 'coverage') {
2601                         inputScenario = 'coverage'
2602                     }
2603                     def inputCoreCLRBuildName = projectFolder + '/' + 
2604                         Utilities.getFullJobName(project, getJobName(configuration, architecture, os, inputScenario, false), isPR)
2605                     // If this is a stress scenario, there isn't any difference in the build job
2606                     // so we didn't create a build only job for windows_nt specific to that stress mode.  Just copy
2607                     // from the default scenario
2608                     def testBuildScenario = scenario
2609                     if (testBuildScenario == 'coverage' || testBuildScenario == 'pri1r2r'|| testBuildScenario == 'gcstress15_pri1r2r') {
2610                         testBuildScenario = 'pri1'
2611                     }
2612                     else if ( testBuildScenario == 'r2r' || isLongGc(testBuildScenario)) {
2613                         testBuildScenario = 'default'
2614                     }
2615                     def inputWindowTestsBuildName = ''
2616                     if (Constants.jitStressModeScenarios.containsKey(testBuildScenario)) {
2617                         inputWindowTestsBuildName = projectFolder + '/' + 
2618                             Utilities.getFullJobName(project, getJobName(configuration, architecture, 'windows_nt', 'default', true), isPR)
2619                     }
2620                     else {
2621                         inputWindowTestsBuildName = projectFolder + '/' + 
2622                             Utilities.getFullJobName(project, getJobName(configuration, architecture, 'windows_nt', testBuildScenario, true), isPR)
2623                     }
2624                     // Enable Server GC for Ubuntu PR builds
2625                     def serverGCString = ''
2626                     
2627                     // Whether or not this test run should be run sequentially instead
2628                     // of in parallel. Only used for long GC tests.
2629                     def sequentialString = ''
2630                     
2631                     // Whether or not this test run should run a specific playlist.
2632                     // Only used for long GC tests.
2633
2634                     // A note - runtest.sh does have "--long-gc" and "--gcsimulator" options
2635                     // for running long GC and GCSimulator tests, respectively. We don't use them
2636                     // here because using a playlist file produces much more readable output on the CI machines
2637                     // and reduces running time.
2638                     def playlistString = ''
2639                      
2640                     if (os == 'Ubuntu' && isPR){
2641                         serverGCString = '--useServerGC'
2642                     }
2643
2644                     // pass --crossgen to runtest.sh for crossgen builds
2645                     def crossgenStr = ''
2646                     def runcrossgentestsStr = ''
2647                     def runjitstressStr = ''
2648                     def runjitstressregsStr = ''
2649                     def runjitmioptsStr = ''
2650                     def runjitforcerelocsStr = ''
2651                     def runjitdisasmStr = ''
2652                     def gcstressStr = ''
2653
2654                     if (scenario == 'r2r' ||
2655                         scenario == 'pri1r2r' ||
2656                         scenario == 'gcstress15_pri1r2r' ||
2657                         Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
2658                             crossgenStr = '--crossgen'
2659                             runcrossgentestsStr = '--runcrossgentests'
2660                                             
2661                             if (scenario == 'r2r_jitstress1'){
2662                                 runjitstressStr = '--jitstress=1'
2663                             }
2664                             else if (scenario == 'r2r_jitstress2') {
2665                                 runjitstressStr = '--jitstress=2'
2666                             }
2667                             else if (scenario == 'r2r_jitstressregs1'){
2668                                 runjitstressregsStr = '--jitstressregs=1'
2669                             }
2670                             else if (scenario == 'r2r_jitstressregs2') {
2671                                 runjitstressregsStr = '--jitstressregs=2'
2672                             }
2673                             else if (scenario == 'r2r_jitstressregs3') {
2674                                 runjitstressregsStr = '--jitstressregs=3'
2675                             }
2676                             else if (scenario == 'r2r_jitstressregs4') {
2677                                 runjitstressregsStr = '--jitstressregs=4'
2678                             }
2679                             else if (scenario == 'r2r_jitstressregs8') {
2680                                 runjitstressregsStr = '--jitstressregs=8'
2681                             }
2682                             else if (scenario == 'r2r_jitstressregsx10') {
2683                                 runjitstressregsStr = '--jitstressregs=x10'
2684                             }
2685                             else if (scenario == 'r2r_jitstressregsx80') {
2686                                 runjitstressregsStr = '--jitstressregs=x80'
2687                             }
2688                             else if (scenario == 'r2r_jitminopts') {
2689                                 runjitmioptsStr = '--jitminopts'
2690                             }
2691                             else if (scenario == 'r2r_jitforcerelocs') {
2692                                 runjitforcerelocsStr = '--jitforcerelocs'
2693                             }
2694                     }
2695                     if  (scenario == 'gcstress15_pri1r2r')
2696                     {
2697                         gcstressStr = '--gcstresslevel=0xF'
2698                     }
2699
2700                     if (scenario == 'jitdiff')
2701                     {
2702                         runjitdisasmStr = '--jitdisasm --crossgen'
2703                     }
2704                     
2705                     if (isLongGc(scenario)) {
2706                         // Long GC tests behave very poorly when they are not
2707                         // the only test running (many of them allocate until OOM).
2708                         sequentialString = '--sequential'
2709                         
2710                         // The Long GC playlist contains all of the tests that are
2711                         // going to be run. The GCSimulator playlist contains all of
2712                         // the GC simulator tests.
2713                         if (scenario == 'longgc') {
2714                             playlistString = '--long-gc --playlist=./tests/longRunningGcTests.txt'
2715                         }
2716                         else if (scenario == 'gcsimulator') {
2717                             playlistString = '--gcsimulator --playlist=./tests/gcSimulatorTests.txt'
2718                         }
2719                     }
2720                     
2721                     def folder = isJITStressJob(scenario) ? 'jitstress' : ''
2722                     def newJob = job(Utilities.getFullJobName(project, jobName, isPR, folder)) {
2723                         // Add parameters for the inputs
2724                     
2725                         parameters {
2726                             stringParam('CORECLR_WINDOWS_BUILD', '', 'Build number to copy CoreCLR windows test binaries from')
2727                             stringParam('CORECLR_BUILD', '', "Build number to copy CoreCLR ${osGroup} binaries from")
2728                         }
2729                     
2730                         steps {
2731                             // Set up the copies
2732                         
2733                             // Coreclr build containing the tests and mscorlib
2734                         
2735                             copyArtifacts(inputWindowTestsBuildName) {
2736                                 excludePatterns('**/testResults.xml', '**/*.ni.dll')
2737                                 buildSelector {
2738                                     buildNumber('${CORECLR_WINDOWS_BUILD}')
2739                                 }
2740                             }
2741
2742                             if (scenario == 'coverage') {
2743
2744                                 // Move coreclr to clr directory
2745                                 shell("rm -rf .clr; mkdir .clr; mv * .clr; mv .git .clr; mv .clr clr")
2746
2747                                 // Build coreclr
2748                                 shell("./clr/build.sh coverage verbose ${lowerConfiguration} ${architecture}")
2749
2750                                 // Remove folders from obj that we don't expect to be covered. May update this later.
2751                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/ToolBox")
2752                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/debug")
2753                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/ilasm")
2754                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/ildasm")
2755                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/dlls/dbgshim")
2756                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/dlls/mscordac")
2757                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/dlls/mscordbi")
2758
2759                                 // Run PAL tests
2760                                 shell("./clr/src/pal/tests/palsuite/runpaltests.sh \$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration} \$(pwd)/clr/bin/paltestout")
2761
2762                                 // Remove obj files for PAL tests so they're not included in coverage results
2763                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/pal/tests")
2764                                 
2765                                 // Unzip the tests first.  Exit with 0
2766                                 shell("unzip -q -o ./clr/bin/tests/tests.zip -d ./clr/bin/tests/Windows_NT.${architecture}.${configuration} || exit 0")
2767
2768                                 // Get corefx
2769                                 shell("git clone https://github.com/dotnet/corefx fx")
2770
2771                                 // Build Linux corefx
2772                                 shell("./fx/build-native.sh -release -buildArch=x64 -os=Linux")
2773                                 shell("./fx/build-managed.sh -release -buildArch=x64 -osgroup=Linux -skiptests")
2774
2775                                 def testEnvOpt = ""
2776                                 def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
2777                                 def createScriptCmds = genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios['heapverify1'], scriptFileName)
2778                                 shell("${createScriptCmds}")
2779                                 testEnvOpt = "--test-env=" + scriptFileName
2780
2781                                 // Run corefx tests
2782                                 shell("""./fx/run-test.sh \\
2783                 --coreclr-bins \$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration} \\
2784                 --mscorlib-bins \$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration} \\
2785                 --corefx-tests \$(pwd)/fx/bin/tests/${osGroup}.AnyCPU.${configuration} \\
2786                 --corefx-native-bins \$(pwd)/fx/bin/${osGroup}.${architecture}.${configuration} \\
2787                 --configurationGroup Release""")
2788
2789
2790                                 // Run coreclr tests w/ workstation GC
2791                                 shell("""./clr/tests/runtest.sh \\
2792                 --testRootDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2793                 --testNativeBinDir=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2794                 --coreClrBinDir=\"\$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2795                 --mscorlibDir=\"\$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2796                 --coreFxBinDir=\"\$(pwd)/fx/bin/${osGroup}.AnyCPU.Release;\$(pwd)/fx/bin/Unix.AnyCPU.Release;\$(pwd)/fx/bin/AnyOS.AnyCPU.Release\" \\
2797                 --coreFxNativeBinDir=\"\$(pwd)/fx/bin/${osGroup}.${architecture}.Release\" \\
2798                 --crossgen --runcrossgentests""")
2799
2800                                 // Run coreclr tests w/ server GC & HeapVerify enabled
2801                                 shell("""./clr/tests/runtest.sh \\
2802                 --testRootDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2803                 --testNativeBinDir=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2804                 --coreOverlayDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}/Tests/coreoverlay\" \\
2805                 --useServerGC ${testEnvOpt}""")
2806
2807                                  // Run long-running coreclr GC tests & produce coverage reports
2808                                 shell("""./clr/tests/runtest.sh \\
2809                 --testRootDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2810                 --testNativeBinDir=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2811                 --coreOverlayDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}/Tests/coreoverlay\" \\
2812                 --long-gc --playlist=\"\$(pwd)/clr/tests/longRunningGcTests.txt\" --coreclr-coverage\\
2813                 --coreclr-objs=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}\" \\
2814                 --coreclr-src=\"\$(pwd)/clr/src\" \\
2815                 --coverage-output-dir=\"\${WORKSPACE}/coverage\" """)
2816
2817                             }
2818                             else {
2819
2820                                 // Coreclr build we are trying to test
2821                             
2822                                 copyArtifacts(inputCoreCLRBuildName) {
2823                                     excludePatterns('**/testResults.xml', '**/*.ni.dll')
2824                                     buildSelector {
2825                                         buildNumber('${CORECLR_BUILD}')
2826                                     }
2827                                 }
2828
2829                                 def corefxFolder = Utilities.getFolderName('dotnet/corefx') + '/' + Utilities.getFolderName(branch)
2830                         
2831                                 // Corefx components.  We now have full stack builds on all distros we test here, so we can copy straight from CoreFX jobs.
2832                                 def osJobName = (os == 'Ubuntu') ? 'ubuntu14.04' : os.toLowerCase()
2833                                 copyArtifacts("${corefxFolder}/${osJobName}_release") {
2834                                     includePatterns('bin/build.tar.gz')
2835                                     buildSelector {
2836                                         latestSuccessful(true)
2837                                     }
2838                                 }
2839                         
2840                                 // Unpack the corefx binaries
2841                                 shell("tar -xf ./bin/build.tar.gz")
2842
2843                                 // Unzip the tests first.  Exit with 0
2844                                 shell("unzip -q -o ./bin/tests/tests.zip -d ./bin/tests/Windows_NT.${architecture}.${configuration} || exit 0")
2845                             
2846                                 // Execute the tests
2847                                 // If we are running a stress mode, we'll set those variables first
2848                                 def testEnvOpt = ""
2849                                 if (Constants.jitStressModeScenarios.containsKey(scenario)) {
2850                                     def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
2851                                     def createScriptCmds = genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios[scenario], scriptFileName)
2852                                     shell("${createScriptCmds}")
2853                                     testEnvOpt = "--test-env=" + scriptFileName
2854                                 }
2855                                 
2856                                 if (isGCStressRelatedTesting(scenario)) {
2857                                     shell('./init-tools.sh')
2858                                 }
2859
2860                                 shell("""./tests/runtest.sh \\
2861                 --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2862                 --testNativeBinDir=\"\${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2863                 --coreClrBinDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2864                 --mscorlibDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2865                 --coreFxBinDir=\"\${WORKSPACE}/bin/${osGroup}.AnyCPU.Release;\${WORKSPACE}/bin/Unix.AnyCPU.Release;\${WORKSPACE}/bin/AnyOS.AnyCPU.Release\" \\
2866                 --coreFxNativeBinDir=\"\${WORKSPACE}/bin/${osGroup}.${architecture}.Release\" \\
2867                 --limitedDumpGeneration \\
2868                 ${testEnvOpt} ${serverGCString} ${gcstressStr} ${crossgenStr} ${runcrossgentestsStr} ${runjitstressStr} ${runjitstressregsStr} ${runjitmioptsStr} ${runjitforcerelocsStr} ${runjitdisasmStr} ${sequentialString} ${playlistString}""")
2869                             }
2870                         }
2871                     }
2872
2873                     if (scenario == 'coverage') {
2874                         // Publish coverage reports
2875                         Utilities.addHtmlPublisher(newJob, '${WORKSPACE}/coverage/Coverage/reports', 'Code Coverage Report', 'coreclr.html')
2876                         // TODO: Add once external email sending is available again
2877                         // addEmailPublisher(newJob, 'clrcoverage@microsoft.com')
2878                     }
2879
2880                     if (scenario == 'jitdiff') {
2881                         Utilities.addArchival(newJob, "bin/tests/${osGroup}.${architecture}.${configuration}/dasm/**")
2882                     }
2883
2884                     // Experimental: If on Ubuntu 14.04, then attempt to pull in crash dump links
2885                     if (os in ['Ubuntu']) {
2886                         SummaryBuilder summaries = new SummaryBuilder()
2887                         summaries.addLinksSummaryFromFile('Crash dumps from this run:', 'dumplings.txt')
2888                         summaries.emit(newJob)
2889                     }
2890
2891                     setMachineAffinity(newJob, os, architecture)
2892                     Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
2893                     // Set timeouts to 240.
2894                     setTestJobTimeOut(newJob, scenario)
2895                     Utilities.addXUnitDotNETResults(newJob, '**/coreclrtests.xml')
2896                 
2897                     // Create a build flow to join together the build and tests required to run this
2898                     // test.
2899                     // Windows CoreCLR build and Linux CoreCLR build (in parallel) ->
2900                     // Linux CoreCLR test
2901                     def flowJobName = getJobName(configuration, architecture, os, scenario, false) + "_flow"
2902                     def fullTestJobName = projectFolder + '/' + newJob.name
2903                     // Add a reference to the input jobs for report purposes
2904                     JobReport.Report.addReference(inputCoreCLRBuildName)
2905                     JobReport.Report.addReference(inputWindowTestsBuildName)
2906                     JobReport.Report.addReference(fullTestJobName)
2907                     def newFlowJob;
2908
2909                     // If this is a coverage job, we don't copy any input coreCLR build - instead, we build it as part of the flow job,
2910                     // so that coverage data can be preserved.
2911                     if (scenario == 'coverage') {
2912                         newFlowJob = buildFlowJob(Utilities.getFullJobName(project, flowJobName, isPR, folder)) {
2913                         buildFlow("""
2914 // Build the input Windows job
2915 windowsBuildJob = build(params, '${inputWindowTestsBuildName}')
2916
2917 // And then build the test build
2918 build(params + [CORECLR_WINDOWS_BUILD: windowsBuildJob.build.number], '${fullTestJobName}')    
2919 """)
2920                         }
2921                     // Normal jobs copy a Windows build & a non-Windows build
2922                     } else {
2923                         newFlowJob = buildFlowJob(Utilities.getFullJobName(project, flowJobName, isPR, folder)) {
2924                         buildFlow("""
2925 // Build the input jobs in parallel
2926 parallel (
2927     { coreclrBuildJob = build(params, '${inputCoreCLRBuildName}') },
2928     { windowsBuildJob = build(params, '${inputWindowTestsBuildName}') }
2929 )
2930     
2931 // And then build the test build
2932 build(params + [CORECLR_BUILD: coreclrBuildJob.build.number, 
2933                 CORECLR_WINDOWS_BUILD: windowsBuildJob.build.number], '${fullTestJobName}')    
2934 """)
2935                         }
2936                     }
2937
2938                     setMachineAffinity(newFlowJob, os, architecture)
2939                     Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
2940                     addTriggers(newFlowJob, branch, isPR, architecture, os, configuration, scenario, true, false, false)
2941                 } // configuration
2942             } // os
2943         } // architecture
2944     } // isPR
2945 } // scenario
2946
2947 JobReport.Report.generateJobReport(out)
2948
2949 // Make the call to generate the help job
2950 Utilities.createHelperJob(this, project, branch,
2951     "Welcome to the ${project} Repository",  // This is prepended to the help message
2952     "Have a nice day!")  // This is appended to the help message.  You might put known issues here.