[ARM32/Linux] cross-architecture build errro: stub for crossgen (#8917)
[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 == 'Ubuntu' || os == 'Windows_NT' || os == 'OSX')
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                     else if (configuration == 'Release') {
1220                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test",
1221                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}.*")
1222                     }
1223                     break
1224                 case 'pri1':
1225                     if (configuration == 'Release') {
1226                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Priority 1 Build and Test")
1227                     }
1228                     break
1229                 case 'ilrt':
1230                     if (configuration == 'Release') {
1231                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} IL RoundTrip Build and Test",
1232                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1233                     }
1234                     break
1235                 case 'r2r':
1236                     if (configuration == 'Checked' || configuration == 'Release') {
1237                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri0 Build & Test",
1238                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1239                     }
1240                     break
1241                 case 'pri1r2r':
1242                     if (configuration == 'Checked' || configuration == 'Release') {
1243                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} R2R pri1 Build & Test",
1244                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1245                     }
1246                     break
1247                 case 'gcstress15_pri1r2r':
1248                     if (configuration == 'Release' || configuration == 'Checked') {
1249                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} GCStress 15 R2R pri1 Build & Test",
1250                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1251                     }
1252                     break
1253                 case 'r2r_jitstress1':
1254                     if (configuration == 'Release' || configuration == 'Checked') {
1255                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstress1 R2R Build & Test",
1256                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1257                     }
1258                     break
1259                 case 'r2r_jitstress2':
1260                     if (configuration == 'Release' || configuration == 'Checked') {
1261                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstress2 R2R Build & Test",
1262                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1263                     }
1264                     break
1265                 case 'r2r_jitstressregs1':
1266                     if (configuration == 'Release' || configuration == 'Checked') {
1267                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs1 R2R Build & Test",
1268                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1269                     }
1270                     break
1271                 case 'r2r_jitstressregs2':
1272                     if (configuration == 'Release' || configuration == 'Checked') {
1273                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs2 R2R Build & Test",
1274                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1275                     }
1276                     break
1277                 case 'r2r_jitstressregs3':
1278                     if (configuration == 'Release' || configuration == 'Checked') {
1279                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs3 R2R Build & Test",
1280                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1281                     }
1282                     break
1283                 case 'r2r_jitstressregs4':
1284                     if (configuration == 'Release' || configuration == 'Checked') {
1285                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs4 R2R Build & Test",
1286                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1287                     }
1288                     break
1289                 case 'r2r_jitstressregs8':
1290                     if (configuration == 'Release' || configuration == 'Checked') {
1291                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregs8 R2R Build & Test",
1292                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1293                     }
1294                     break
1295                 case 'r2r_jitstressregsx10':
1296                     if (configuration == 'Release' || configuration == 'Checked') {
1297                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregsx10 R2R Build & Test",
1298                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1299                     }
1300                     break
1301                 case 'r2r_jitstressregsx80':
1302                     if (configuration == 'Release' || configuration == 'Checked') {
1303                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} jitstressregsx80 R2R Build & Test",
1304                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1305                     }
1306                     break
1307                 case 'r2r_jitminopts':
1308                     if (configuration == 'Release' || configuration == 'Checked') {
1309                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} JITMinOpts R2R Build & Test",
1310                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1311                     }
1312                     break
1313                 case 'r2r_jitforcerelocs':
1314                     if (configuration == 'Release' || configuration == 'Checked') {
1315                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} ForceRelocs R2R Build & Test",
1316                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")  
1317                     }
1318                     break
1319                 case 'longgc':
1320                     if (configuration == 'Release') {
1321                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Long-Running GC Build & Test",
1322                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1323                     }
1324                     break
1325                 case 'gcsimulator':
1326                     if (configuration == 'Release') {
1327                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} GC Simulator",
1328                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1329                     }
1330                     break
1331                 case 'standalone_gc':
1332                     if (configuration == 'Release' || configuration == 'Checked') {
1333                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Standalone GC",
1334                             "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1335                     }
1336                     break
1337                 case 'minopts':
1338                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - MinOpts)",
1339                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1340                     break
1341                 case 'forcerelocs':                         
1342                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ForceRelocs)",
1343                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1344                     break                           
1345                 case 'jitstress1':
1346                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStress=1)",
1347                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1348                     break
1349                 case 'jitstress2':
1350                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStress=2)",
1351                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1352                     break
1353                 case 'jitstressregs1':
1354                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=1)",
1355                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1356                     break                       
1357                 case 'jitstressregs2':
1358                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=2)",
1359                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1360                     break                       
1361                 case 'jitstressregs3':
1362                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=3)",
1363                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1364                     break                       
1365                 case 'jitstressregs4':      
1366                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=4)",
1367                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1368                     break                       
1369                 case 'jitstressregs8':
1370                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=8)",
1371                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1372                     break                       
1373                 case 'jitstressregs0x10':
1374                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=0x10)",
1375                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1376                     break                       
1377                 case 'jitstressregs0x80':
1378                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - JitStressRegs=0x80)",
1379                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1380                     break       
1381                 case 'jitstress2_jitstressregs1':
1382                 case 'jitstress2_jitstressregs2':
1383                 case 'jitstress2_jitstressregs3':
1384                 case 'jitstress2_jitstressregs4':
1385                 case 'jitstress2_jitstressregs8':
1386                 case 'jitstress2_jitstressregs0x10':
1387                 case 'jitstress2_jitstressregs0x80':
1388                 case 'gcstress0x3': 
1389                 case 'gcstress0xc':
1390                 case 'zapdisable':
1391                 case 'heapverify1':
1392                 case 'gcstress0xc_zapdisable':
1393                 case 'gcstress0xc_zapdisable_jitstress2':
1394                 case 'gcstress0xc_zapdisable_heapverify1':
1395                 case 'gcstress0xc_jitstress1':
1396                 case 'gcstress0xc_jitstress2':
1397                 case 'gcstress0xc_minopts_heapverify1':                                 
1398                     def displayStr = getStressModeDisplayName(scenario)
1399                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ${displayStr})",
1400                        "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*")
1401                     break                                   
1402                 case 'corefx_baseline':
1403                         case 'corefx_minopts':
1404                         case 'corefx_jitstress1':
1405                         case 'corefx_jitstress2':
1406                         case 'corefx_jitstressregs1':
1407                         case 'corefx_jitstressregs2':
1408                         case 'corefx_jitstressregs3':
1409                         case 'corefx_jitstressregs4':
1410                         case 'corefx_jitstressregs8':
1411                         case 'corefx_jitstressregs0x10':
1412                         case 'corefx_jitstressregs0x80':
1413                             def displayName = 'CoreFx ' + getStressModeDisplayName(scenario)
1414                             assert (os == 'Windows_NT') || (os in Constants.crossList)
1415                             Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ${displayName})",
1416                                "(?i).*test\\W+${os}\\W+${scenario}.*")
1417                             break                       
1418                 default:
1419                     println("Unknown scenario: ${os} ${architecture} ${scenario}");
1420                     assert false
1421                     break
1422             }
1423             break
1424         // editor brace matching: }
1425         case 'x86compatjit': // editor brace matching: {
1426             assert (os == 'Windows_NT')
1427             def arch = 'x86'
1428             def jit = 'compatjit'
1429             switch (scenario) {
1430                 case 'default':
1431                     if (configuration == 'Checked') {
1432                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test",
1433                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}.*")
1434                     }
1435                     break
1436                 case 'pri1':
1437                     if (configuration == 'Release') {
1438                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Priority 1 Build and Test",
1439                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+Priority 1 Build and Test.*")
1440                     }
1441                     break
1442                 case 'ilrt':
1443                     if (configuration == 'Release') {
1444                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} IL RoundTrip Build and Test",
1445                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1446                     }
1447                     break
1448                 case 'r2r':
1449                     if (configuration == 'Checked' || configuration == 'Release') {
1450                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} R2R pri0 Build & Test",
1451                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1452                     }
1453                     break
1454                 case 'pri1r2r':
1455                     if (configuration == 'Checked' || configuration == 'Release') {
1456                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} R2R pri1 Build & Test",
1457                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1458                     }
1459                     break
1460                 case 'gcstress15_pri1r2r':
1461                     if (configuration == 'Release' || configuration == 'Checked') {
1462                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} GCStress 15 R2R pri1 Build & Test",
1463                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1464                     }
1465                     break
1466                 case 'r2r_jitstress1':
1467                     if (configuration == 'Release' || configuration == 'Checked') {
1468                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstress1 R2R Build & Test",
1469                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1470                     }
1471                     break
1472                 case 'r2r_jitstress2':
1473                     if (configuration == 'Release' || configuration == 'Checked') {
1474                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstress2 R2R Build & Test",
1475                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1476                     }
1477                     break
1478                 case 'r2r_jitstressregs1':
1479                     if (configuration == 'Release' || configuration == 'Checked') {
1480                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs1 R2R Build & Test",
1481                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1482                     }
1483                     break
1484                 case 'r2r_jitstressregs2':
1485                     if (configuration == 'Release' || configuration == 'Checked') {
1486                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs2 R2R Build & Test",
1487                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1488                     }
1489                     break
1490                 case 'r2r_jitstressregs3':
1491                     if (configuration == 'Release' || configuration == 'Checked') {
1492                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs3 R2R Build & Test",
1493                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1494                     }
1495                     break
1496                 case 'r2r_jitstressregs4':
1497                     if (configuration == 'Release' || configuration == 'Checked') {
1498                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs4 R2R Build & Test",
1499                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1500                     }
1501                     break
1502                 case 'r2r_jitstressregs8':
1503                     if (configuration == 'Release' || configuration == 'Checked') {
1504                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs8 R2R Build & Test",
1505                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1506                     }
1507                     break
1508                 case 'r2r_jitstressregsx10':
1509                     if (configuration == 'Release' || configuration == 'Checked') {
1510                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregsx10 R2R Build & Test",
1511                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1512                     }
1513                     break
1514                 case 'r2r_jitstressregsx80':
1515                     if (configuration == 'Release' || configuration == 'Checked') {
1516                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregsx80 R2R Build & Test",
1517                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1518                     }
1519                     break
1520                 case 'r2r_jitminopts':
1521                     if (configuration == 'Release' || configuration == 'Checked') {
1522                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} JITMinOpts R2R Build & Test",
1523                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1524                     }
1525                     break
1526                 case 'r2r_jitforcerelocs':
1527                     if (configuration == 'Release' || configuration == 'Checked') {
1528                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} ForceRelocs R2R Build & Test",
1529                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1530                     }
1531                     break
1532                 case 'longgc':
1533                     if (configuration == 'Release') {
1534                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Long-Running GC Build & Test",
1535                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1536                     }
1537                     break
1538                 case 'gcsimulator':
1539                     if (configuration == 'Release') {
1540                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} GC Simulator",
1541                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1542                     }
1543                     break
1544                 case 'standalone_gc':
1545                     if (configuration == 'Release' || configuration == 'Checked') {
1546                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Standalone GC", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
1547                     }
1548                     break
1549                 case 'minopts':
1550                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - MinOpts)",
1551                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1552                     break
1553                 case 'forcerelocs':                         
1554                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - ForceRelocs)",
1555                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1556                     break                           
1557                 case 'jitstress1':
1558                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStress=1)",
1559                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1560                     break
1561                 case 'jitstress2':
1562                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStress=2)",
1563                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1564                     break
1565                 case 'jitstressregs1':
1566                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=1)",
1567                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1568                     break                       
1569                 case 'jitstressregs2':
1570                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=2)",
1571                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1572                     break                       
1573                 case 'jitstressregs3':
1574                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=3)",
1575                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1576                     break                       
1577                 case 'jitstressregs4':      
1578                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=4)",
1579                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1580                     break                       
1581                 case 'jitstressregs8':
1582                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=8)",
1583                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1584                     break                       
1585                 case 'jitstressregs0x10':
1586                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=0x10)",
1587                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1588                     break                       
1589                 case 'jitstressregs0x80':
1590                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - JitStressRegs=0x80)",
1591                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1592                     break       
1593                 case 'jitstress2_jitstressregs1':
1594                 case 'jitstress2_jitstressregs2':
1595                 case 'jitstress2_jitstressregs3':
1596                 case 'jitstress2_jitstressregs4':
1597                 case 'jitstress2_jitstressregs8':
1598                 case 'jitstress2_jitstressregs0x10':
1599                 case 'jitstress2_jitstressregs0x80':
1600                 case 'gcstress0x3': 
1601                 case 'gcstress0xc':
1602                 case 'zapdisable':
1603                 case 'heapverify1':
1604                 case 'gcstress0xc_zapdisable':
1605                 case 'gcstress0xc_zapdisable_jitstress2':
1606                 case 'gcstress0xc_zapdisable_heapverify1':
1607                 case 'gcstress0xc_jitstress1':
1608                 case 'gcstress0xc_jitstress2':
1609                 case 'gcstress0xc_minopts_heapverify1':                                 
1610                     def displayStr = getStressModeDisplayName(scenario)
1611                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - ${displayStr})",
1612                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1613                     break                                   
1614                 case 'corefx_baseline':
1615                 case 'corefx_minopts':
1616                 case 'corefx_jitstress1':
1617                 case 'corefx_jitstress2':
1618                 case 'corefx_jitstressregs1':
1619                 case 'corefx_jitstressregs2':
1620                 case 'corefx_jitstressregs3':
1621                 case 'corefx_jitstressregs4':
1622                 case 'corefx_jitstressregs8':
1623                 case 'corefx_jitstressregs0x10':
1624                 case 'corefx_jitstressregs0x80':
1625                     def displayName = 'CoreFx ' + getStressModeDisplayName(scenario)
1626                     assert (os == 'Windows_NT')
1627                     Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test (Jit - ${displayName})",
1628                        "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1629                     break
1630                 default:
1631                     println("Unknown scenario: ${os} ${arch} ${jit} ${scenario}");
1632                     assert false
1633                     break
1634             }
1635             break
1636         // editor brace matching: }
1637         case 'x86lb': // editor brace matching: {
1638             assert (os == 'Windows_NT')
1639             assert (scenario == 'default' ||
1640                     scenario == 'r2r' ||
1641                     scenario == 'pri1r2r' ||
1642                     scenario == 'gcstress15_pri1r2r' ||
1643                     scenario == 'longgc' ||
1644                     scenario == 'gcsimulator' ||
1645                     Constants.r2rJitStressScenarios.indexOf(scenario) != -1)
1646
1647             def arch = 'x86'
1648             def jit = 'legacy_backend'
1649             switch (scenario) {
1650                 case 'default':
1651                     if (configuration == 'Checked') {
1652                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Build and Test",
1653                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}.*")
1654                     }
1655                     break
1656                 case 'r2r':
1657                     if (configuration == 'Release') {
1658                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} R2R pri0 Build & Test",
1659                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1660                     }
1661                     break
1662                 case 'pri1r2r':
1663                     if (configuration == 'Release') {
1664                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} R2R pri1 Build & Test",
1665                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1666                     }
1667                     break
1668                 case 'gcstress15_pri1r2r':
1669                     if (configuration == 'Release') {
1670                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} GCStress 15 R2R pri1 Build & Test",
1671                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1672                     }
1673                     break
1674                 case 'r2r_jitstress1':
1675                     if (configuration == 'Release' || configuration == 'Checked') {
1676                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstress1 R2R Build & Test",
1677                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1678                     }
1679                     break
1680                 case 'r2r_jitstress2':
1681                     if (configuration == 'Release' || configuration == 'Checked') {
1682                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstress2 R2R Build & Test",
1683                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1684                     }
1685                     break
1686                 case 'r2r_jitstressregs1':
1687                     if (configuration == 'Release' || configuration == 'Checked') {
1688                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs1 R2R Build & Test",
1689                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1690                     }
1691                     break
1692                 case 'r2r_jitstressregs2':
1693                     if (configuration == 'Release' || configuration == 'Checked') {
1694                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs2 R2R Build & Test",
1695                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1696                     }
1697                     break
1698                 case 'r2r_jitstressregs3':
1699                     if (configuration == 'Release' || configuration == 'Checked') {
1700                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs3 R2R Build & Test",
1701                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1702                     }
1703                     break
1704                 case 'r2r_jitstressregs4':
1705                     if (configuration == 'Release' || configuration == 'Checked') {
1706                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs4 R2R Build & Test",
1707                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1708                     }
1709                     break
1710                 case 'r2r_jitstressregs8':
1711                     if (configuration == 'Release' || configuration == 'Checked') {
1712                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregs8 R2R Build & Test",
1713                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1714                     }
1715                     break
1716                 case 'r2r_jitstressregsx10':
1717                     if (configuration == 'Release' || configuration == 'Checked') {
1718                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregsx10 R2R Build & Test",
1719                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1720                     }
1721                     break
1722                 case 'r2r_jitstressregsx80':
1723                     if (configuration == 'Release' || configuration == 'Checked') {
1724                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitstressregsx80 R2R Build & Test",
1725                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1726                     }
1727                     break
1728                 case 'r2r_jitminopts':
1729                     if (configuration == 'Release' || configuration == 'Checked') {
1730                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitminopts R2R Build & Test",
1731                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1732                     }
1733                     break
1734                 case 'r2r_jitforcerelocs':
1735                     if (configuration == 'Release' || configuration == 'Checked') {
1736                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} jitforcerelocs R2R Build & Test",
1737                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1738                     }
1739                     break
1740                 case 'longgc':
1741                     if (configuration == 'Release') {
1742                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} Long-Running GC Build & Test",
1743                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")  
1744                     }
1745                     break
1746                 case 'gcsimulator':
1747                     if (configuration == 'Release') {
1748                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${arch} ${jit} ${configuration} GC Simulator",
1749                             "(?i).*test\\W+${os}\\W+${arch}\\W+${jit}\\W+${configuration}\\W+${scenario}.*")
1750                     }
1751                     break
1752                 case 'standalone_gc':
1753                     if (configuration == 'Release' || configuration == 'Checked') {
1754                         Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Standalone GC", "(?i).*test\\W+${os}\\W+${configuration}\\W+${scenario}.*")
1755                     }
1756                     break
1757                 default:
1758                     println("Unknown scenario: ${os} ${arch} ${jit} ${scenario}");
1759                     assert false
1760                     break
1761             }
1762             break
1763         // editor brace matching: }
1764         default:
1765             println("Unknown architecture: ${architecture}");
1766             assert false
1767             break
1768     }
1769 }
1770
1771 def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR, def architecture, def configuration, def os, def enableCorefxTesting, def isBuildOnly, def isLinuxEmulatorBuild) {
1772     def buildCommands = [];
1773     def osGroup = getOSGroup(os)
1774     def lowerConfiguration = configuration.toLowerCase()
1775
1776     // Calculate the build steps, archival, and xunit results
1777     switch (os) {
1778         case 'Windows_NT': // editor brace matching: {
1779             switch (architecture) {
1780                 case 'x64':
1781                 case 'x86':
1782                 case 'x86compatjit':
1783                 case 'x86lb':
1784                     def arch = architecture
1785                     def buildOpts = ''
1786                     if (architecture == 'x86compatjit') {
1787                         arch = 'x86'
1788                         buildOpts = 'compatjitcrossgen'
1789                     }
1790                     else if (architecture == 'x86lb') {
1791                         arch = 'x86'
1792                         buildOpts = 'legacyjitcrossgen'
1793                     }
1794                     
1795                     if (Constants.jitStressModeScenarios.containsKey(scenario) ||
1796                             scenario == 'default' ||
1797                             scenario == 'r2r' ||
1798                             scenario == 'jitdiff' ||
1799                             Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
1800                         buildOpts += enableCorefxTesting ? ' skiptests' : ''
1801                         buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${arch} ${buildOpts}"
1802                     }
1803
1804                     // For Pri 1 tests, we must shorten the output test binary path names.
1805                     // if __TestIntermediateDir is already set, build-test.cmd will
1806                     // output test binaries to that directory. If it is not set, the 
1807                     // binaries are sent to a default directory whose name is about
1808                     // 35 characters long.
1809
1810                     else if (scenario == 'pri1' || scenario == 'pri1r2r' || scenario == 'gcstress15_pri1r2r'|| scenario == 'coverage') {
1811                         buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${arch} ${buildOpts} -priority=1"
1812                     }
1813                     else if (scenario == 'ilrt') {
1814                         // First do the build with skiptests and then build the tests with ilasm roundtrip
1815                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} ${buildOpts} skiptests"
1816                         buildCommands += "set __TestIntermediateDir=int&&build-test.cmd ${lowerConfiguration} ${arch} -ilasmroundtrip"
1817                     }
1818                     else if (isLongGc(scenario)) {
1819                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} ${buildOpts} skiptests"
1820                         buildCommands += "set __TestIntermediateDir=int&&build-test.cmd ${lowerConfiguration} ${arch}"
1821                     }
1822                     else if (scenario == 'standalone_gc') {
1823                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} ${buildOpts} buildstandalonegc"
1824                     }
1825                     else if (scenario == 'formatting') {
1826                         buildCommands += "python -u tests\\scripts\\format.py -c %WORKSPACE% -o Windows_NT -a ${arch}"
1827                         Utilities.addArchival(newJob, "format.patch", "", true, false)
1828                         break
1829                     }
1830                     else {
1831                         println("Unknown scenario: ${scenario}")
1832                         assert false
1833                     }
1834                     
1835                     // If we are running a stress mode, we should write out the set of key
1836                     // value env pairs to a file at this point and then we'll pass that to runtest.cmd
1837
1838                     if (!isBuildOnly) {
1839                         //If this is a crossgen build, pass 'crossgen' to runtest.cmd
1840                         def crossgenStr = ''
1841                         def runcrossgentestsStr = ''
1842                         def runjitstressStr = ''
1843                         def runjitstressregsStr = ''
1844                         def runjitmioptsStr = ''
1845                         def runjitforcerelocsStr = ''
1846                         def runjitdisasmStr = ''
1847                         def gcstressStr = ''
1848                         def runtestArguments = ''
1849                         def gcTestArguments = ''
1850
1851                         if (scenario == 'r2r' ||
1852                             scenario == 'pri1r2r' ||
1853                             scenario == 'gcstress15_pri1r2r' ||
1854                             Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
1855                                 crossgenStr = 'crossgen'
1856                                 runcrossgentestsStr = 'runcrossgentests'
1857                             
1858                                 if (scenario == 'r2r_jitstress1'){
1859                                     runjitstressStr = 'jitstress 1'
1860                                 }
1861                                 else if (scenario == 'r2r_jitstress2') {
1862                                     runjitstressStr = 'jitstress 2'
1863                                 }
1864                                 else if (scenario == 'r2r_jitstressregs1'){
1865                                     runjitstressregsStr = 'jitstressregs 1'
1866                                 }
1867                                 else if (scenario == 'r2r_jitstressregs2') {
1868                                     runjitstressregsStr = 'jitstressregs 2'
1869                                 }
1870                                 else if (scenario == 'r2r_jitstressregs3') {
1871                                     runjitstressregsStr = 'jitstressregs 3'
1872                                 }
1873                                 else if (scenario == 'r2r_jitstressregs4') {
1874                                     runjitstressregsStr = 'jitstressregs 4'
1875                                 }
1876                                 else if (scenario == 'r2r_jitstressregs8') {
1877                                     runjitstressregsStr = 'jitstressregs 8'
1878                                 }
1879                                 else if (scenario == 'r2r_jitstressregsx10') {
1880                                     runjitstressregsStr = 'jitstressregs x10'
1881                                 }
1882                                 else if (scenario == 'r2r_jitstressregsx80') {
1883                                     runjitstressregsStr = 'jitstressregs x80'
1884                                 }
1885                                 else if (scenario == 'r2r_jitminopts') {
1886                                     runjitmioptsStr = 'jitminopts'
1887                                 }
1888                                 else if (scenario == 'r2r_jitforcerelocs') {
1889                                     runjitforcerelocsStr = 'jitforcerelocs'
1890                                 }
1891                         }
1892                         if (scenario == 'gcstress15_pri1r2r')
1893                         {
1894                             gcstressStr = 'gcstresslevel 0xF'
1895                         }
1896
1897                         if (scenario == 'jitdiff')
1898                         {
1899                             runjitdisasmStr = 'jitdisasm crossgen'
1900                         }
1901
1902                         if (isLongGc(scenario)) {
1903                             gcTestArguments = "${scenario} sequential"
1904                         }
1905
1906                         runtestArguments = "${lowerConfiguration} ${arch} ${gcstressStr} ${crossgenStr} ${runcrossgentestsStr} ${runjitstressStr} ${runjitstressregsStr} ${runjitmioptsStr} ${runjitforcerelocsStr} ${runjitdisasmStr} ${gcTestArguments}"
1907
1908                         if (Constants.jitStressModeScenarios.containsKey(scenario)) {
1909                             def stepScriptLocation = "%WORKSPACE%\\SetStressModes.bat"
1910                             buildCommands += genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios[scenario], stepScriptLocation)
1911
1912                             if (enableCorefxTesting) {
1913                                 def workspaceRelativeFxRoot = "_/fx"
1914                                 def absoluteFxRoot = "%WORKSPACE%\\_\\fx"
1915
1916                                 buildCommands += "python %WORKSPACE%\\tests\\scripts\\run-corefx-tests.py -arch ${arch} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${branch} -env_script ${stepScriptLocation}"
1917
1918                                 setTestJobTimeOut(newJob, scenario)
1919
1920                                 // Archive and process (only) the test results
1921                                 Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/tests/**/testResults.xml")
1922                                 Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/tests/**/testResults.xml")
1923                             }
1924                             else {
1925                                 buildCommands += "%WORKSPACE%\\tests\\runtest.cmd ${runtestArguments} TestEnv ${stepScriptLocation}"
1926                             }
1927                         }
1928                         else if (architecture == 'x64' || architecture == 'x86') {
1929                             buildCommands += "tests\\runtest.cmd ${runtestArguments}"
1930                         }                                        
1931                         else if (architecture == 'x86compatjit') {
1932                             def testEnvLocation = "%WORKSPACE%\\tests\\x86\\compatjit_x86_testenv.cmd"
1933                             buildCommands += "tests\\runtest.cmd ${runtestArguments} Exclude0 x86_legacy_backend_issues.targets TestEnv ${testEnvLocation}"
1934                         }
1935                         else if (architecture == 'x86lb') {
1936                             def testEnvLocation = "%WORKSPACE%\\tests\\x86\\legacyjit_x86_testenv.cmd"
1937                             buildCommands += "tests\\runtest.cmd ${runtestArguments} Exclude0 x86_legacy_backend_issues.targets TestEnv ${testEnvLocation}"
1938                         }
1939                     }
1940
1941                     if (!enableCorefxTesting) {
1942                         // Run the rest of the build    
1943                         // Build the mscorlib for the other OS's
1944                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} linuxmscorlib"
1945                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} freebsdmscorlib"
1946                         buildCommands += "build.cmd ${lowerConfiguration} ${arch} osxmscorlib"
1947
1948                         // Zip up the tests directory so that we don't use so much space/time copying
1949                         // 10s of thousands of files around.
1950                         buildCommands += "powershell -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${arch}.${configuration}', '.\\bin\\tests\\tests.zip')\"";
1951
1952                         if (!Constants.jitStressModeScenarios.containsKey(scenario)) {
1953                             // For windows, pull full test results and test drops for x86/x64.
1954                             // No need to pull for stress mode scenarios (downstream builds use the default scenario)
1955                             Utilities.addArchival(newJob, "bin/Product/**,bin/tests/tests.zip")
1956                         }
1957
1958                         if (scenario == 'jitdiff') {
1959                             // retrive jit-dasm output for base commit, and run jit-diff
1960                             if (!isBuildOnly) {
1961                                 // if this is a build only job, we want to keep the default (build) artifacts for the flow job
1962                                 Utilities.addArchival(newJob, "bin/tests/${osGroup}.${arch}.${configuration}/dasm/**")
1963                             }
1964                         }
1965                         
1966                         if (!isBuildOnly) {
1967                             if (architecture == 'x64' || !isPR) {
1968                                 Utilities.addXUnitDotNETResults(newJob, 'bin/**/TestRun*.xml')
1969                             }
1970                             setTestJobTimeOut(newJob, scenario)
1971                         }
1972                     }
1973                     break
1974                 case 'arm':
1975                     assert (scenario == 'default')
1976                     
1977                     // Set time out
1978                     setTestJobTimeOut(newJob, scenario)
1979
1980                     if ( lowerConfiguration == "debug" ) {
1981                         // For Debug builds, we will do a P1 test build
1982                         buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} -priority=1"
1983                     }
1984                     else {
1985                         buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture}"
1986                     }
1987                     // Add archival.
1988                     Utilities.addArchival(newJob, "bin/Product/**")
1989                     break
1990                 case 'arm64':
1991                     assert (scenario == 'default') || (scenario == 'pri1r2r') || (scenario == 'gcstress0x3') || (scenario == 'gcstress0xc')
1992                     // Set time out
1993                     setTestJobTimeOut(newJob, scenario)
1994
1995                     // Debug runs take too long to run. So build job only.
1996                     if (lowerConfiguration == "debug") {
1997                        buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} toolset_dir C:\\ats2"
1998                     }
1999                     else {
2000                        buildCommands += "set __TestIntermediateDir=int&&build.cmd skiptests ${lowerConfiguration} ${architecture} toolset_dir C:\\ats2"
2001                        // Test build and run are launched together.
2002                        buildCommands += "python tests\\scripts\\arm64_post_build.py -repo_root %WORKSPACE% -arch ${architecture} -build_type ${lowerConfiguration} -scenario ${scenario} -key_location C:\\tools\\key.txt"
2003                        //Utilities.addXUnitDotNETResults(newJob, 'bin/tests/testResults.xml')
2004                     }
2005
2006                     // Add archival.
2007                     Utilities.addArchival(newJob, "bin/Product/**")
2008                     break
2009                 default:
2010                     println("Unknown architecture: ${architecture}");
2011                     assert false
2012                     break
2013             }
2014             break
2015         // editor brace matching: }
2016         case 'Ubuntu':
2017         case 'Ubuntu16.04':
2018         case 'Ubuntu16.10':
2019         case 'Debian8.4':
2020         case 'OSX':
2021         case 'FreeBSD':
2022         case 'CentOS7.1':
2023         case 'RHEL7.2':
2024         case 'OpenSUSE13.2':
2025         case 'OpenSUSE42.1':
2026         case 'Fedora23': // editor brace matching: {
2027             switch (architecture) {
2028                 case 'x64':
2029                 case 'x86':
2030                 case 'x86compatjit':
2031                 case 'x86lb':
2032                     def arch = architecture
2033                     if (architecture == 'x86compatjit' || architecture == 'x86lb') {
2034                         arch = 'x86'
2035                     }
2036
2037                     if (scenario == 'formatting') {
2038                         buildCommands += "python tests/scripts/format.py -c \${WORKSPACE} -o Linux -a ${arch}"
2039                         Utilities.addArchival(newJob, "format.patch", "", true, false)
2040                         break
2041                     }
2042
2043                     def standaloneGc = ''
2044                     if (scenario == 'standalone_gc') {
2045                         standaloneGc = 'buildstandalonegc'
2046                     }
2047                 
2048                     if (!enableCorefxTesting) {
2049                         // We run pal tests on all OS but generate mscorlib (and thus, nuget packages)
2050                         // only on supported OS platforms.
2051                         if ((os == 'FreeBSD') || (os == 'OpenSUSE13.2'))
2052                         {
2053                             buildCommands += "./build.sh skipmscorlib verbose ${lowerConfiguration} ${arch} ${standaloneGc}"
2054                         }
2055                         else
2056                         {
2057                             def bootstrapRid = Utilities.getBoostrapPublishRid(os)
2058                             def bootstrapRidEnv = bootstrapRid != null ? "__PUBLISH_RID=${bootstrapRid} " : ''
2059                             buildCommands += "${bootstrapRidEnv}./build.sh verbose ${lowerConfiguration} ${arch} ${standaloneGc}"
2060                         }
2061                         buildCommands += "src/pal/tests/palsuite/runpaltests.sh \${WORKSPACE}/bin/obj/${osGroup}.${arch}.${configuration} \${WORKSPACE}/bin/paltestout"
2062                     
2063                         // Set time out
2064                         setTestJobTimeOut(newJob, scenario)
2065                         // Basic archiving of the build
2066                         Utilities.addArchival(newJob, "bin/Product/**,bin/obj/*/tests/**/*.dylib,bin/obj/*/tests/**/*.so")
2067                         // And pal tests
2068                         Utilities.addXUnitDotNETResults(newJob, '**/pal_tests.xml')
2069                     }
2070                     else {
2071                         // Corefx stress testing                                        
2072                         assert os == 'Ubuntu'
2073                         assert architecture == 'x64'
2074                         assert lowerConfiguration == 'checked'
2075                         assert Constants.jitStressModeScenarios.containsKey(scenario)
2076                         
2077                         // Build coreclr
2078                         buildCommands += "./build.sh verbose ${lowerConfiguration} ${architecture}"
2079                         
2080                         def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
2081                         buildCommands += genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios[scenario], scriptFileName)
2082
2083                         // Build and text corefx
2084                         def workspaceRelativeFxRoot = "_/fx"
2085                         def absoluteFxRoot = "\$WORKSPACE/${workspaceRelativeFxRoot}"
2086
2087                         buildCommands += "python \$WORKSPACE/tests/scripts/run-corefx-tests.py -arch ${arch} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${branch} -env_script ${scriptFileName}"
2088
2089                         setTestJobTimeOut(newJob, scenario)
2090
2091                         // Archive and process (only) the test results
2092                         Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/tests/**/testResults.xml")
2093                         Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/tests/**/testResults.xml")
2094                     }
2095                     break
2096                 case 'arm64':
2097                     // We don't run the cross build except on Ubuntu
2098                     assert os == 'Ubuntu'
2099                     
2100                     buildCommands += """echo \"Using rootfs in /opt/aarch64-linux-gnu-root\"
2101                         ROOTFS_DIR=/opt/aarch64-linux-gnu-root ./build.sh skipmscorlib arm64 cross verbose ${lowerConfiguration}"""
2102                     
2103                     // Basic archiving of the build, no pal tests
2104                     Utilities.addArchival(newJob, "bin/Product/**")
2105                     break
2106                 case 'arm':
2107                     // All builds for ARM architecture are run on Ubuntu currently
2108                     assert os == 'Ubuntu'
2109                     if (isLinuxEmulatorBuild == false) {
2110                         buildCommands += """echo \"Using rootfs in /opt/arm-liux-genueabihf-root\"
2111                             ROOTFS_DIR=/opt/arm-linux-genueabihf-root ./build.sh skipmscorlib arm cross verbose ${lowerConfiguration}"""
2112                         
2113                         // Basic archiving of the build, no pal tests
2114                         Utilities.addArchival(newJob, "bin/Product/**")
2115                         break
2116                     }
2117                     else {
2118                         // Make sure the build configuration is either of debug or release
2119                         assert ( lowerConfiguration == 'debug' ) || ( lowerConfiguration == 'release' )
2120
2121                         // Setup variables to hold emulator folder path and the rootfs mount path
2122                         def armemul_path = '/opt/linux-arm-emulator'
2123                         def armrootfs_mountpath = '/opt/linux-arm-emulator-root'
2124
2125                         // Unzip the Windows test binaries first. Exit with 0
2126                         buildCommands += "unzip -q -o ./bin/tests/tests.zip -d ./bin/tests/Windows_NT.x64.${configuration} || exit 0"
2127
2128                         // Unpack the corefx binaries
2129                         buildCommands += "tar -xf ./bin/build.tar.gz"
2130
2131                         // Call the ARM emulator build script to cross build and test using the ARM emulator rootfs
2132                         buildCommands += """./tests/scripts/arm32_ci_script.sh \\
2133                         --emulatorPath=${armemul_path} \\
2134                         --mountPath=${armrootfs_mountpath} \\
2135                         --buildConfig=${lowerConfiguration} \\
2136                         --testRootDir=./bin/tests/Windows_NT.x64.${configuration} \\
2137                         --coreFxNativeBinDir=./bin/Linux.armel.${configuration} \\
2138                         --coreFxBinDir=\"./bin/Linux.AnyCPU.${configuration};./bin/Unix.AnyCPU.${configuration};./bin/AnyOS.AnyCPU.${configuration}\" \\
2139                         --testDirFile=./tests/testsRunningInsideARM.txt"""
2140
2141
2142                         // Basic archiving of the build
2143                         Utilities.addArchival(newJob, "bin/Product/**")
2144                         break
2145                     }
2146                 default:
2147                     println("Unknown architecture: ${architecture}");
2148                     assert false
2149                     break
2150             }
2151             break
2152         // editor brace matching: }
2153         default:
2154             println("Unknown os: ${os}");
2155             assert false
2156             break
2157     } // os
2158
2159     return buildCommands
2160 }
2161
2162 // Additional scenario which can alter behavior
2163
2164 def combinedScenarios = Constants.basicScenarios + Constants.jitStressModeScenarios.keySet()
2165 combinedScenarios.each { scenario ->
2166     [true, false].each { isPR ->
2167         Constants.architectureList.each { architecture ->
2168             Constants.configurationList.each { configuration ->
2169                 Constants.osList.each { os ->
2170                     // If the OS is Windows_NT_BuildOnly, set the isBuildOnly flag to true
2171                     // and reset the os to Windows_NT
2172                     def isBuildOnly = false
2173                     if (os == 'Windows_NT_BuildOnly') {
2174                         isBuildOnly = true
2175                         os = 'Windows_NT'
2176                     }
2177
2178                     // WinArm32 is only built for Debug and Release
2179                     if (os == 'Windows_NT' && architecture == 'arm')
2180                     {
2181                         if (configuration == 'Checked')
2182                         {
2183                             return
2184                         }
2185                     }
2186                     // If the OS is LinuxARMEmulator and arch is arm, set the isLinuxEmulatorBuild
2187                     // flag to true and reset the os to Ubuntu
2188                     // The isLinuxEmulatorBuild flag will be used at a later time to execute the right
2189                     // set of build commands
2190                     // The tuples (LinuxARMEmulator, other architectures) are not handled and control returns
2191                     def isLinuxEmulatorBuild = false
2192                     if (os == 'LinuxARMEmulator' && architecture == 'arm') {
2193                         // Cross Builds only in Debug and Release modes allowed
2194                         if ( configuration == 'Checked' ) {
2195                             return
2196                         }
2197
2198                         isLinuxEmulatorBuild = true
2199                         os = 'Ubuntu'
2200                     } else if (os == 'LinuxARMEmulator') {
2201                         return
2202                     }
2203
2204                     // Skip totally unimplemented (in CI) configurations.
2205                     switch (architecture) {
2206                         case 'arm64':
2207                             // Windows only
2208                             if (os != 'Windows_NT' || isBuildOnly) {
2209                                 return
2210                             }
2211                             break
2212                         case 'arm':
2213                             if ((os != 'Ubuntu') && (os != 'Windows_NT')) {
2214                                 return
2215                             }
2216                             break
2217                         case 'x86':
2218                         case 'x86compatjit':
2219                         case 'x86lb':
2220                             // Skip non-windows
2221                             if (os != 'Windows_NT') {
2222                                 return
2223                             }
2224                             break
2225                         case 'x64':
2226                             // Everything implemented
2227                             break
2228                         default:
2229                             println("Unknown architecture: ${architecture}")
2230                             assert false
2231                             break
2232                     }
2233
2234                     // Skip scenarios (blanket skipping for jit stress modes, which are good most everywhere
2235                     // with checked builds
2236                     def enableCorefxTesting = false
2237                     if (Constants.jitStressModeScenarios.containsKey(scenario)) {
2238                         if (configuration != 'Checked') {
2239                             return
2240                         }
2241                         
2242                         enableCorefxTesting = isCorefxTesting(scenario)
2243                         
2244                         // Since these are just execution time differences,
2245                         // skip platforms that don't execute the tests here (Windows_NT only)
2246                         def isEnabledOS = (os == 'Windows_NT') || (os == 'Ubuntu' && enableCorefxTesting)
2247                         if (!isEnabledOS || isBuildOnly) {
2248                             return
2249                         }
2250                         
2251                         switch (architecture) {
2252                             case 'arm64':
2253                                 if ((scenario != 'gcstress0x3') && (scenario != 'gcstress0xc')) {
2254                                     return
2255                                 }
2256                                 break
2257                             case 'x64':
2258                             case 'x86':
2259                                 // Everything implemented
2260                                 break
2261                             case 'x86compatjit':
2262                             case 'x86lb':
2263                                 // No stress modes for compatjit.dll, legacyjit.dll.
2264                                 // (There's no technical reason we couldn't allow these.)
2265                                 return
2266                             default:
2267                                 return
2268                         }
2269                     }
2270                     else {
2271                         // If this is a r2r jitstress, jitstressregs, jitminopts, or forcerelocs scenario
2272                         // and configuration is not Checked, bail out.
2273                         if (configuration != 'Checked' && Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
2274                             return;
2275                         }
2276
2277                         // Skip scenarios
2278                         switch (scenario) {
2279                             case 'pri1':
2280                                 // The pri1 build isn't necessary except for Windows_NT.  Non-Windows NT uses
2281                                 // the default scenario build
2282                                 if (os != 'Windows_NT') {
2283                                     return
2284                                 }
2285                                 // Only x64 for now
2286                                 if (architecture != 'x64') {
2287                                     return
2288                                 }
2289                                 break
2290                             case 'ilrt':
2291                                 // The ilrt build isn't necessary except for Windows_NT.  Non-Windows NT uses
2292                                 // the default scenario build
2293                                 if (os != 'Windows_NT') {
2294                                     return
2295                                 }
2296                                 // Only x64 for now
2297                                 if (architecture != 'x64') {
2298                                     return
2299                                 }
2300                                 // Release only
2301                                 if (configuration != 'Release') {
2302                                     return
2303                                 }
2304                                 break
2305                             case 'jitdiff':
2306                                 if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX') {
2307                                     return
2308                                 }
2309                                 if (architecture != 'x64') {
2310                                     return
2311                                 }
2312                                 if (configuration != 'Checked') {
2313                                     return
2314                                 }
2315                                 break
2316                             case 'r2r':
2317                                 // The r2r build isn't necessary except for Windows_NT.  Non-Windows NT uses
2318                                 // the default scenario build
2319                                 if (os != 'Windows_NT') {
2320                                     return
2321                                 }
2322                                 if (architecture != 'x64') {
2323                                     return
2324                                 }
2325                                 break
2326                             case 'pri1r2r':
2327                                 // The pri1r2r build isn't necessary except for Windows_NT.  Non-Windows NT uses
2328                                 // the default scenario build
2329                                 if (os != 'Windows_NT') {
2330                                     return
2331                                 }
2332                                 if (architecture != 'x64') {
2333                                     if (architecture != 'arm64' || configuration == 'Debug') {
2334                                         return
2335                                     }
2336                                 }
2337                                 break
2338                             case 'gcstress15_pri1r2r':
2339                             case 'r2r_jitstress1':
2340                             case 'r2r_jitstress2':
2341                             case 'r2r_jitstressregs1':
2342                             case 'r2r_jitstressregs2':
2343                             case 'r2r_jitstressregs3':
2344                             case 'r2r_jitstressregs4':
2345                             case 'r2r_jitstressregs8':
2346                             case 'r2r_jitstressregsx10':
2347                             case 'r2r_jitstressregsx80':
2348                             case 'r2r_jitminopts':
2349                             case 'r2r_jitforcerelocs':
2350                                 // The above builds are not necessary except for Windows_NT.  Non-Windows NT uses
2351                                 // the default scenario build
2352                                 if (os != 'Windows_NT') {
2353                                     return
2354                                 }
2355                                 if (architecture != 'x64') {
2356                                     return
2357                                 }
2358                                 break
2359                             case 'longgc':
2360                             case 'gcsimulator':
2361                                 if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX') {
2362                                     return
2363                                 }
2364                                 if (architecture != 'x64') {
2365                                     return
2366                                 }
2367                                 if (configuration != 'Release') {
2368                                     return
2369                                 }
2370                                 break
2371                             case 'standalone_gc':
2372                                 if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX') {
2373                                     return
2374                                 }
2375
2376                                 if (architecture != 'x64') {
2377                                     return
2378                                 }
2379
2380                                 if (configuration != 'Release' && configuration != 'Checked') {
2381                                     return
2382                                 }
2383                                 break
2384                             // We need Windows x64 Release bits for the code coverage build
2385                             case 'coverage':
2386                                 if (os != 'Windows_NT') {
2387                                     return
2388                                 }
2389                                 if (architecture != 'x64') {
2390                                     return
2391                                 }
2392                                 if (configuration != 'Release') {
2393                                     return
2394                                 }
2395                                 break
2396                             // We only run Windows and Ubuntu x64 Checked for formatting right now
2397                             case 'formatting':
2398                                 if (os != 'Windows_NT' && os != 'Ubuntu') {
2399                                     return
2400                                 }
2401                                 if (architecture != 'x64') {
2402                                     return
2403                                 }
2404                                 if (configuration != 'Checked') {
2405                                     return
2406                                 }
2407                                 if (isBuildOnly) {
2408                                     return
2409                                 }
2410                                 break
2411                             case 'default':
2412                                 // Nothing skipped
2413                                 break
2414                             default:
2415                                 println("Unknown scenario: ${scenario}")
2416                                 assert false
2417                                 break
2418                         }
2419                     }
2420                 
2421                     // Calculate names
2422                     def lowerConfiguration = configuration.toLowerCase()
2423                     def jobName = getJobName(configuration, architecture, os, scenario, isBuildOnly, isLinuxEmulatorBuild)
2424                     def folderName = isJITStressJob(scenario) ? 'jitstress' : '';
2425                     
2426                     // Create the new job
2427                     def newJob = job(Utilities.getFullJobName(project, jobName, isPR, folderName)) {}
2428                     
2429                     setMachineAffinity(newJob, os, architecture)
2430
2431                     // Add all the standard options
2432                     Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
2433                     addTriggers(newJob, branch, isPR, architecture, os, configuration, scenario, false, isBuildOnly, isLinuxEmulatorBuild)
2434                 
2435                     def buildCommands = calculateBuildCommands(newJob, scenario, branch, isPR, architecture, configuration, os, enableCorefxTesting, isBuildOnly, isLinuxEmulatorBuild)
2436                     def osGroup = getOSGroup(os)
2437
2438                     newJob.with {
2439                         steps {
2440                             if (os == 'Windows_NT') {
2441                                 buildCommands.each { buildCommand ->
2442                                     batchFile(buildCommand)
2443                                 }
2444                             }
2445                             else {
2446                                 // Setup corefx and Windows test binaries for Linux ARM Emulator Build
2447                                 if (isLinuxEmulatorBuild) {
2448                                     // Define the Windows Tests and Corefx build job names
2449                                     def WindowTestsName = projectFolder + '/' +
2450                                                           Utilities.getFullJobName(project,
2451                                                                                    getJobName(lowerConfiguration,
2452                                                                                               'x64' ,
2453                                                                                               'windows_nt',
2454                                                                                               'default',
2455                                                                                               true),
2456                                                                                    false)
2457                                     def corefxFolder = Utilities.getFolderName('dotnet/corefx') + '/' +
2458                                                        Utilities.getFolderName(branch)
2459
2460                                     // Copy the Windows test binaries and the Corefx build binaries
2461                                     copyArtifacts(WindowTestsName) {
2462                                         excludePatterns('**/testResults.xml', '**/*.ni.dll')
2463                                         buildSelector {
2464                                             latestSuccessful(true)
2465                                         }
2466                                     }
2467                                     copyArtifacts("${corefxFolder}/linuxarmemulator_softfp_cross_${lowerConfiguration}") {
2468                                         includePatterns('bin/build.tar.gz')
2469                                         buildSelector {
2470                                             latestSaved()
2471                                         }
2472                                     }
2473                                 }
2474
2475                                 buildCommands.each { buildCommand ->
2476                                     shell(buildCommand)
2477                                 }
2478                             }
2479                         }
2480                     } // newJob.with
2481                     
2482                 } // os
2483             } // configuration
2484         } // architecture
2485     } // isPR
2486 } // scenario
2487
2488
2489 // Create the Linux/OSX/CentOS coreclr test leg for debug and release and each scenario
2490 combinedScenarios.each { scenario ->
2491     [true, false].each { isPR ->
2492         // Architectures.  x64 only at this point
2493         ['x64'].each { architecture ->
2494             // Put the OS's supported for coreclr cross testing here
2495             Constants.crossList.each { os ->
2496                 Constants.configurationList.each { configuration ->
2497
2498                     if (Constants.jitStressModeScenarios.containsKey(scenario)) {
2499                         if (configuration != 'Checked') {
2500                             return
2501                         }
2502                         if (isCorefxTesting(scenario)) {
2503                             return
2504                         }
2505                         //Skip stress modes for these scenarios
2506                         if (os == 'RHEL7.2' || os == 'Debian8.4' || os == 'OpenSUSE13.2') {
2507                             return
2508                         }
2509                     }
2510                     // If this is a r2r jitstress, jitstressregs, jitminopts or forcerelocs scenario
2511                     // and configuration is not Checked, bail out.
2512                     else if (configuration != 'Checked' && Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
2513                         return;
2514                     }
2515                     // For CentOS, we only want Checked/Release pri1 builds.
2516                     else if (os == 'CentOS7.1') {
2517                         if (scenario != 'pri1' &&
2518                             scenario != 'r2r' && 
2519                             scenario != 'pri1r2r' && 
2520                             scenario != 'gcstress15_pri1r2r' &&
2521                             Constants.r2rJitStressScenarios.indexOf(scenario) == -1) {
2522                             return
2523                         }
2524                         if (configuration != 'Checked' && configuration != 'Release') {
2525                             return
2526                         }
2527                     }
2528                     // For RedHat, Debian, and OpenSUSE, we only do Release pri1 builds.
2529                     else if (os == 'RHEL7.2' || os == 'Debian8.4' || os == 'OpenSUSE13.2') {
2530                         if (scenario != 'pri1') {
2531                             return
2532                         }
2533                         if (configuration != 'Release') {
2534                             return
2535                         }
2536                     }
2537                     else {
2538                         // Skip scenarios
2539                         switch (scenario) {
2540                             case 'pri1':
2541                                 // Nothing skipped
2542                                 break
2543                             case 'ilrt':
2544                                 // Release only
2545                                 if (configuration != 'Release') {
2546                                     return
2547                                 }
2548                                 break
2549                             case 'jitdiff':
2550                                 if (configuration != 'Checked') {
2551                                     return;
2552                                 }
2553                             case 'r2r':
2554                                 //Skip configs that aren't Checked or Release (so just Debug, for now)
2555                                 if (configuration != 'Checked' && configuration != 'Release') {
2556                                     return
2557                                 }
2558                                 break
2559                             case 'pri1r2r':
2560                                 //Skip configs that aren't Checked or Release (so just Debug, for now)
2561                                 if (configuration != 'Checked' && configuration != 'Release') {
2562                                     return
2563                                 }
2564                                 break
2565                             case 'gcstress15_pri1r2r':
2566                             case 'r2r_jitstress1':
2567                             case 'r2r_jitstress2':
2568                             case 'r2r_jitstressregs1':
2569                             case 'r2r_jitstressregs2':
2570                             case 'r2r_jitstressregs3':
2571                             case 'r2r_jitstressregs4':
2572                             case 'r2r_jitstressregs8':
2573                             case 'r2r_jitstressregsx10':
2574                             case 'r2r_jitstressregsx80':
2575                             case 'r2r_jitminopts':
2576                             case 'r2r_jitforcerelocs':
2577                                 //Skip configs that aren't Checked or Release (so just Debug, for now)
2578                                 if (configuration != 'Checked' && configuration != 'Release') {
2579                                     return
2580                                 }
2581                                 break
2582                             case 'longgc':
2583                             case 'gcsimulator':
2584                                 // Long GC tests take a long time on non-Release builds
2585                                 if (configuration != 'Release') {
2586                                     return
2587                                 }
2588                                 break
2589                             case 'standalone_gc':
2590                                 if (configuration != 'Release' && configuration != 'Checked') {
2591                                     return
2592                                 }
2593                             case 'coverage':
2594                                 //We only want Ubuntu Release for coverage
2595                                 if (os != 'Ubuntu') {
2596                                     return
2597                                 }
2598                                 if (configuration != 'Release') {
2599                                     return
2600                                 }
2601                             case 'formatting':
2602                                 return
2603                             case 'default':
2604                                 // Nothing skipped
2605                                 break
2606                             default:
2607                                 println("Unknown scenario: ${scenario}")
2608                                 assert false
2609                                 break
2610                         }
2611                     }
2612                     
2613                     def lowerConfiguration = configuration.toLowerCase()
2614                     def osGroup = getOSGroup(os)
2615                     def jobName = getJobName(configuration, architecture, os, scenario, false) + "_tst"
2616                     
2617                     // Unless this is a coverage test run, we want to copy over the default build of coreclr.
2618                     def inputScenario = 'default'
2619                     if (scenario == 'coverage') {
2620                         inputScenario = 'coverage'
2621                     }
2622                     def inputCoreCLRBuildName = projectFolder + '/' + 
2623                         Utilities.getFullJobName(project, getJobName(configuration, architecture, os, inputScenario, false), isPR)
2624                     // If this is a stress scenario, there isn't any difference in the build job
2625                     // so we didn't create a build only job for windows_nt specific to that stress mode.  Just copy
2626                     // from the default scenario
2627                     def testBuildScenario = scenario
2628                     if (testBuildScenario == 'coverage' || testBuildScenario == 'pri1r2r'|| testBuildScenario == 'gcstress15_pri1r2r') {
2629                         testBuildScenario = 'pri1'
2630                     }
2631                     else if ( testBuildScenario == 'r2r' || isLongGc(testBuildScenario)) {
2632                         testBuildScenario = 'default'
2633                     }
2634                     def inputWindowTestsBuildName = ''
2635                     if (Constants.jitStressModeScenarios.containsKey(testBuildScenario)) {
2636                         inputWindowTestsBuildName = projectFolder + '/' + 
2637                             Utilities.getFullJobName(project, getJobName(configuration, architecture, 'windows_nt', 'default', true), isPR)
2638                     }
2639                     else {
2640                         inputWindowTestsBuildName = projectFolder + '/' + 
2641                             Utilities.getFullJobName(project, getJobName(configuration, architecture, 'windows_nt', testBuildScenario, true), isPR)
2642                     }
2643                     // Enable Server GC for Ubuntu PR builds
2644                     def serverGCString = ''
2645                     
2646                     // Whether or not this test run should be run sequentially instead
2647                     // of in parallel. Only used for long GC tests.
2648                     def sequentialString = ''
2649                     
2650                     // Whether or not this test run should run a specific playlist.
2651                     // Only used for long GC tests.
2652
2653                     // A note - runtest.sh does have "--long-gc" and "--gcsimulator" options
2654                     // for running long GC and GCSimulator tests, respectively. We don't use them
2655                     // here because using a playlist file produces much more readable output on the CI machines
2656                     // and reduces running time.
2657                     def playlistString = ''
2658                      
2659                     if (os == 'Ubuntu' && isPR){
2660                         serverGCString = '--useServerGC'
2661                     }
2662
2663                     // pass --crossgen to runtest.sh for crossgen builds
2664                     def crossgenStr = ''
2665                     def runcrossgentestsStr = ''
2666                     def runjitstressStr = ''
2667                     def runjitstressregsStr = ''
2668                     def runjitmioptsStr = ''
2669                     def runjitforcerelocsStr = ''
2670                     def runjitdisasmStr = ''
2671                     def gcstressStr = ''
2672
2673                     if (scenario == 'r2r' ||
2674                         scenario == 'pri1r2r' ||
2675                         scenario == 'gcstress15_pri1r2r' ||
2676                         Constants.r2rJitStressScenarios.indexOf(scenario) != -1) {
2677                             crossgenStr = '--crossgen'
2678                             runcrossgentestsStr = '--runcrossgentests'
2679                                             
2680                             if (scenario == 'r2r_jitstress1'){
2681                                 runjitstressStr = '--jitstress=1'
2682                             }
2683                             else if (scenario == 'r2r_jitstress2') {
2684                                 runjitstressStr = '--jitstress=2'
2685                             }
2686                             else if (scenario == 'r2r_jitstressregs1'){
2687                                 runjitstressregsStr = '--jitstressregs=1'
2688                             }
2689                             else if (scenario == 'r2r_jitstressregs2') {
2690                                 runjitstressregsStr = '--jitstressregs=2'
2691                             }
2692                             else if (scenario == 'r2r_jitstressregs3') {
2693                                 runjitstressregsStr = '--jitstressregs=3'
2694                             }
2695                             else if (scenario == 'r2r_jitstressregs4') {
2696                                 runjitstressregsStr = '--jitstressregs=4'
2697                             }
2698                             else if (scenario == 'r2r_jitstressregs8') {
2699                                 runjitstressregsStr = '--jitstressregs=8'
2700                             }
2701                             else if (scenario == 'r2r_jitstressregsx10') {
2702                                 runjitstressregsStr = '--jitstressregs=x10'
2703                             }
2704                             else if (scenario == 'r2r_jitstressregsx80') {
2705                                 runjitstressregsStr = '--jitstressregs=x80'
2706                             }
2707                             else if (scenario == 'r2r_jitminopts') {
2708                                 runjitmioptsStr = '--jitminopts'
2709                             }
2710                             else if (scenario == 'r2r_jitforcerelocs') {
2711                                 runjitforcerelocsStr = '--jitforcerelocs'
2712                             }
2713                     }
2714                     if  (scenario == 'gcstress15_pri1r2r')
2715                     {
2716                         gcstressStr = '--gcstresslevel=0xF'
2717                     }
2718
2719                     if (scenario == 'jitdiff')
2720                     {
2721                         runjitdisasmStr = '--jitdisasm --crossgen'
2722                     }
2723                     
2724                     if (isLongGc(scenario)) {
2725                         // Long GC tests behave very poorly when they are not
2726                         // the only test running (many of them allocate until OOM).
2727                         sequentialString = '--sequential'
2728                         
2729                         // The Long GC playlist contains all of the tests that are
2730                         // going to be run. The GCSimulator playlist contains all of
2731                         // the GC simulator tests.
2732                         if (scenario == 'longgc') {
2733                             playlistString = '--long-gc --playlist=./tests/longRunningGcTests.txt'
2734                         }
2735                         else if (scenario == 'gcsimulator') {
2736                             playlistString = '--gcsimulator --playlist=./tests/gcSimulatorTests.txt'
2737                         }
2738                     }
2739                     
2740                     def folder = isJITStressJob(scenario) ? 'jitstress' : ''
2741                     def newJob = job(Utilities.getFullJobName(project, jobName, isPR, folder)) {
2742                         // Add parameters for the inputs
2743                     
2744                         parameters {
2745                             stringParam('CORECLR_WINDOWS_BUILD', '', 'Build number to copy CoreCLR windows test binaries from')
2746                             stringParam('CORECLR_BUILD', '', "Build number to copy CoreCLR ${osGroup} binaries from")
2747                         }
2748                     
2749                         steps {
2750                             // Set up the copies
2751                         
2752                             // Coreclr build containing the tests and mscorlib
2753                         
2754                             copyArtifacts(inputWindowTestsBuildName) {
2755                                 excludePatterns('**/testResults.xml', '**/*.ni.dll')
2756                                 buildSelector {
2757                                     buildNumber('${CORECLR_WINDOWS_BUILD}')
2758                                 }
2759                             }
2760
2761                             if (scenario == 'coverage') {
2762
2763                                 // Move coreclr to clr directory
2764                                 shell("rm -rf .clr; mkdir .clr; mv * .clr; mv .git .clr; mv .clr clr")
2765
2766                                 // Build coreclr
2767                                 shell("./clr/build.sh coverage verbose ${lowerConfiguration} ${architecture}")
2768
2769                                 // Remove folders from obj that we don't expect to be covered. May update this later.
2770                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/ToolBox")
2771                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/debug")
2772                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/ilasm")
2773                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/ildasm")
2774                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/dlls/dbgshim")
2775                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/dlls/mscordac")
2776                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/dlls/mscordbi")
2777
2778                                 // Run PAL tests
2779                                 shell("./clr/src/pal/tests/palsuite/runpaltests.sh \$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration} \$(pwd)/clr/bin/paltestout")
2780
2781                                 // Remove obj files for PAL tests so they're not included in coverage results
2782                                 shell("rm -rf ./clr/bin/obj/Linux.x64.Release/src/pal/tests")
2783                                 
2784                                 // Unzip the tests first.  Exit with 0
2785                                 shell("unzip -q -o ./clr/bin/tests/tests.zip -d ./clr/bin/tests/Windows_NT.${architecture}.${configuration} || exit 0")
2786
2787                                 // Get corefx
2788                                 shell("git clone https://github.com/dotnet/corefx fx")
2789
2790                                 // CoreFX is changing their output format and scripts, pick a stable version until all that work has landed.
2791                                 shell("git -C ./fx checkout 551fe49174378adcbf785c0ab12fc69355cef6e8")
2792
2793                                 // Build Linux corefx
2794                                 shell("./fx/build-native.sh -release -buildArch=x64 -os=Linux")
2795                                 shell("./fx/build-managed.sh -release -buildArch=x64 -osgroup=Linux -skiptests")
2796
2797                                 def testEnvOpt = ""
2798                                 def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
2799                                 def createScriptCmds = genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios['heapverify1'], scriptFileName)
2800                                 shell("${createScriptCmds}")
2801                                 testEnvOpt = "--test-env=" + scriptFileName
2802
2803                                 // Run corefx tests
2804                                 shell("""./fx/run-test.sh \\
2805                 --coreclr-bins \$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration} \\
2806                 --mscorlib-bins \$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration} \\
2807                 --corefx-tests \$(pwd)/fx/bin/tests/${osGroup}.AnyCPU.${configuration} \\
2808                 --corefx-native-bins \$(pwd)/fx/bin/${osGroup}.${architecture}.${configuration} \\
2809                 --configurationGroup Release""")
2810
2811
2812                                 // Run coreclr tests w/ workstation GC
2813                                 shell("""./clr/tests/runtest.sh \\
2814                 --testRootDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2815                 --testNativeBinDir=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2816                 --coreClrBinDir=\"\$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2817                 --mscorlibDir=\"\$(pwd)/clr/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2818                 --coreFxBinDir=\"\$(pwd)/fx/bin/${osGroup}.AnyCPU.Release;\$(pwd)/fx/bin/Unix.AnyCPU.Release;\$(pwd)/fx/bin/AnyOS.AnyCPU.Release\" \\
2819                 --coreFxNativeBinDir=\"\$(pwd)/fx/bin/${osGroup}.${architecture}.Release\" \\
2820                 --crossgen --runcrossgentests""")
2821
2822                                 // Run coreclr tests w/ server GC & HeapVerify enabled
2823                                 shell("""./clr/tests/runtest.sh \\
2824                 --testRootDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2825                 --testNativeBinDir=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2826                 --coreOverlayDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}/Tests/coreoverlay\" \\
2827                 --useServerGC ${testEnvOpt}""")
2828
2829                                  // Run long-running coreclr GC tests & produce coverage reports
2830                                 shell("""./clr/tests/runtest.sh \\
2831                 --testRootDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2832                 --testNativeBinDir=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2833                 --coreOverlayDir=\"\$(pwd)/clr/bin/tests/Windows_NT.${architecture}.${configuration}/Tests/coreoverlay\" \\
2834                 --long-gc --playlist=\"\$(pwd)/clr/tests/longRunningGcTests.txt\" --coreclr-coverage\\
2835                 --coreclr-objs=\"\$(pwd)/clr/bin/obj/${osGroup}.${architecture}.${configuration}\" \\
2836                 --coreclr-src=\"\$(pwd)/clr/src\" \\
2837                 --coverage-output-dir=\"\${WORKSPACE}/coverage\" """)
2838
2839                             }
2840                             else {
2841
2842                                 // Coreclr build we are trying to test
2843                             
2844                                 copyArtifacts(inputCoreCLRBuildName) {
2845                                     excludePatterns('**/testResults.xml', '**/*.ni.dll')
2846                                     buildSelector {
2847                                         buildNumber('${CORECLR_BUILD}')
2848                                     }
2849                                 }
2850
2851                                 def corefxFolder = Utilities.getFolderName('dotnet/corefx') + '/' + Utilities.getFolderName(branch)
2852                         
2853                                 // Corefx components.  We now have full stack builds on all distros we test here, so we can copy straight from CoreFX jobs.
2854                                 def osJobName = (os == 'Ubuntu') ? 'ubuntu14.04' : os.toLowerCase()
2855                                 copyArtifacts("${corefxFolder}/${osJobName}_release") {
2856                                     includePatterns('bin/build.tar.gz')
2857                                     buildSelector {
2858                                         latestSaved()
2859                                     }
2860                                 }
2861                         
2862                                 // Unpack the corefx binaries
2863                                 shell("tar -xf ./bin/build.tar.gz")
2864
2865                                 // Unzip the tests first.  Exit with 0
2866                                 shell("unzip -q -o ./bin/tests/tests.zip -d ./bin/tests/Windows_NT.${architecture}.${configuration} || exit 0")
2867                             
2868                                 // Execute the tests
2869                                 // If we are running a stress mode, we'll set those variables first
2870                                 def testEnvOpt = ""
2871                                 if (Constants.jitStressModeScenarios.containsKey(scenario)) {
2872                                     def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
2873                                     def createScriptCmds = genStressModeScriptStep(os, scenario, Constants.jitStressModeScenarios[scenario], scriptFileName)
2874                                     shell("${createScriptCmds}")
2875                                     testEnvOpt = "--test-env=" + scriptFileName
2876                                 }
2877                                 
2878                                 if (isGCStressRelatedTesting(scenario)) {
2879                                     shell('./init-tools.sh')
2880                                 }
2881
2882                                 shell("""./tests/runtest.sh \\
2883                 --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
2884                 --testNativeBinDir=\"\${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration}/tests\" \\
2885                 --coreClrBinDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2886                 --mscorlibDir=\"\${WORKSPACE}/bin/Product/${osGroup}.${architecture}.${configuration}\" \\
2887                 --coreFxBinDir=\"\${WORKSPACE}/bin/${osGroup}.AnyCPU.Release;\${WORKSPACE}/bin/Unix.AnyCPU.Release;\${WORKSPACE}/bin/AnyOS.AnyCPU.Release\" \\
2888                 --coreFxNativeBinDir=\"\${WORKSPACE}/bin/${osGroup}.${architecture}.Release\" \\
2889                 --limitedDumpGeneration \\
2890                 ${testEnvOpt} ${serverGCString} ${gcstressStr} ${crossgenStr} ${runcrossgentestsStr} ${runjitstressStr} ${runjitstressregsStr} ${runjitmioptsStr} ${runjitforcerelocsStr} ${runjitdisasmStr} ${sequentialString} ${playlistString}""")
2891                             }
2892                         }
2893                     }
2894
2895                     if (scenario == 'coverage') {
2896                         // Publish coverage reports
2897                         Utilities.addHtmlPublisher(newJob, '${WORKSPACE}/coverage/Coverage/reports', 'Code Coverage Report', 'coreclr.html')
2898                         // TODO: Add once external email sending is available again
2899                         // addEmailPublisher(newJob, 'clrcoverage@microsoft.com')
2900                     }
2901
2902                     if (scenario == 'jitdiff') {
2903                         Utilities.addArchival(newJob, "bin/tests/${osGroup}.${architecture}.${configuration}/dasm/**")
2904                     }
2905
2906                     // Experimental: If on Ubuntu 14.04, then attempt to pull in crash dump links
2907                     if (os in ['Ubuntu']) {
2908                         SummaryBuilder summaries = new SummaryBuilder()
2909                         summaries.addLinksSummaryFromFile('Crash dumps from this run:', 'dumplings.txt')
2910                         summaries.emit(newJob)
2911                     }
2912
2913                     setMachineAffinity(newJob, os, architecture)
2914                     Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
2915                     // Set timeouts to 240.
2916                     setTestJobTimeOut(newJob, scenario)
2917                     Utilities.addXUnitDotNETResults(newJob, '**/coreclrtests.xml')
2918                 
2919                     // Create a build flow to join together the build and tests required to run this
2920                     // test.
2921                     // Windows CoreCLR build and Linux CoreCLR build (in parallel) ->
2922                     // Linux CoreCLR test
2923                     def flowJobName = getJobName(configuration, architecture, os, scenario, false) + "_flow"
2924                     def fullTestJobName = projectFolder + '/' + newJob.name
2925                     // Add a reference to the input jobs for report purposes
2926                     JobReport.Report.addReference(inputCoreCLRBuildName)
2927                     JobReport.Report.addReference(inputWindowTestsBuildName)
2928                     JobReport.Report.addReference(fullTestJobName)
2929                     def newFlowJob;
2930
2931                     // If this is a coverage job, we don't copy any input coreCLR build - instead, we build it as part of the flow job,
2932                     // so that coverage data can be preserved.
2933                     if (scenario == 'coverage') {
2934                         newFlowJob = buildFlowJob(Utilities.getFullJobName(project, flowJobName, isPR, folder)) {
2935                         buildFlow("""
2936 // Build the input Windows job
2937 windowsBuildJob = build(params, '${inputWindowTestsBuildName}')
2938
2939 // And then build the test build
2940 build(params + [CORECLR_WINDOWS_BUILD: windowsBuildJob.build.number], '${fullTestJobName}')    
2941 """)
2942                         }
2943                     // Normal jobs copy a Windows build & a non-Windows build
2944                     } else {
2945                         newFlowJob = buildFlowJob(Utilities.getFullJobName(project, flowJobName, isPR, folder)) {
2946                         buildFlow("""
2947 // Build the input jobs in parallel
2948 parallel (
2949     { coreclrBuildJob = build(params, '${inputCoreCLRBuildName}') },
2950     { windowsBuildJob = build(params, '${inputWindowTestsBuildName}') }
2951 )
2952     
2953 // And then build the test build
2954 build(params + [CORECLR_BUILD: coreclrBuildJob.build.number, 
2955                 CORECLR_WINDOWS_BUILD: windowsBuildJob.build.number], '${fullTestJobName}')    
2956 """)
2957                         }
2958                     }
2959
2960                     setMachineAffinity(newFlowJob, os, architecture)
2961                     Utilities.standardJobSetup(newFlowJob, project, isPR, "*/${branch}")
2962                     addTriggers(newFlowJob, branch, isPR, architecture, os, configuration, scenario, true, false, false)
2963                 } // configuration
2964             } // os
2965         } // architecture
2966     } // isPR
2967 } // scenario
2968
2969 JobReport.Report.generateJobReport(out)
2970
2971 // Make the call to generate the help job
2972 Utilities.createHelperJob(this, project, branch,
2973     "Welcome to the ${project} Repository",  // This is prepended to the help message
2974     "Have a nice day!")  // This is appended to the help message.  You might put known issues here.