netci.groovy 5.2 KB
Newer Older
1 2 3
// Groovy Script: http://www.groovy-lang.org/syntax.html
// Jenkins DSL: https://github.com/jenkinsci/job-dsl-plugin/wiki

4
import jobs.generation.Utilities;
J
Jared Parsons 已提交
5

6
def project = GithubProject
J
Jared Parsons 已提交
7

8
// Email the results of aborted / failed jobs to our infrastructure alias
9 10 11 12 13 14 15 16 17 18 19
static void addEmailPublisher(def myJob) {
  myJob.with {
    publishers {
      extendedEmail('$DEFAULT_RECIPIENTS, cc:mlinfraswat@microsoft.com', '$DEFAULT_SUBJECT', '$DEFAULT_CONTENT') {
        trigger('Aborted', '$PROJECT_DEFAULT_SUBJECT', '$PROJECT_DEFAULT_CONTENT', null, true, true, true, true)
        trigger('Failure', '$PROJECT_DEFAULT_SUBJECT', '$PROJECT_DEFAULT_CONTENT', null, true, true, true, true)
      }
    }
  }
}

20 21
// Generates the standard trigger phrases.  This is the regex which ends up matching lines like:
//  test win32 please
J
Jared Parsons 已提交
22
static String generateTriggerPhrase(String jobName, String opsysName, String triggerKeyword = 'this') {
23 24 25
    return "(?i).*test\\W+(${jobName.replace('_', '/').substring(7)}|${opsysName}|${triggerKeyword}|${opsysName}\\W+${triggerKeyword}|${triggerKeyword}\\W+${opsysName})\\W+please.*";
}

26
static void addRoslynJob(def myJob, String jobName, String branchName, String triggerPhrase, Boolean triggerPhraseOnly = false) {
27
  def includePattern = "Binaries/**/*.pdb,Binaries/**/*.xml,Binaries/**/*.log,Binaries/**/*.dmp,Binaries/**/*.zip,Binaries/**/*.png,Binaries/**/*.xml"
28
  def excludePattern = "Binaries/Obj/**,Binaries/Bootstrap/**,Binaries/**/nuget*.zip"
J
Jared Parsons 已提交
29
  Utilities.addArchival(myJob, includePattern, excludePattern)
30

31
  // Create the standard job.  This will setup parameter, SCM, timeout, etc ...
32
  def projectName = 'dotnet/roslyn'
J
Jared Parsons 已提交
33
  def isPr = branchName == 'prtest'
34
  def defaultBranch = "*/${branchName}"
35
  Utilities.standardJobSetup(myJob, projectName, isPr, defaultBranch)
36 37

  // Need to setup the triggers for the job
J
Jared Parsons 已提交
38
  if (isPr) {
J
Jared Parsons 已提交
39 40
    def contextName = jobName.replace('_', '/').substring(7)
    Utilities.addGithubPRTrigger(myJob, contextName, triggerPhrase, triggerPhraseOnly)
41
  } else {
42
    Utilities.addGithubPushTrigger(myJob)
43 44 45 46
    addEmailPublisher(myJob)
  }
}

A
Artur Spychaj 已提交
47
def branchNames = []
48
['master', 'future', 'stabilization', 'future-stabilization', 'hotfixes', 'prtest', 'microupdate'].each { branchName ->
A
Artur Spychaj 已提交
49 50 51 52 53
  def shortBranchName = branchName.substring(0, 6)
  def jobBranchName = shortBranchName in branchNames ? branchName : shortBranchName
  branchNames << jobBranchName

  // folder("${jobBranchName}")
54
  ['win', 'linux', 'mac'].each { opsys ->
A
Artur Spychaj 已提交
55
    // folder("${jobBranchName}/${opsys.substring(0, 3)}")
56 57
    ['dbg', 'rel'].each { configuration ->
      if ((configuration == 'dbg') || ((branchName != 'prtest') && (opsys == 'win'))) {
A
Artur Spychaj 已提交
58
        // folder("${jobBranchName}/${opsys.substring(0, 3)}/${configuration}")
59 60
        ['unit32', 'unit64'].each { buildTarget ->
          if ((opsys == 'win') || (buildTarget == 'unit32')) {
A
Artur Spychaj 已提交
61
            def jobName = "roslyn_${jobBranchName}_${opsys.substring(0, 3)}_${configuration}_${buildTarget}"
62 63 64 65
            def myJob = job(jobName) {
              description('')
            }

66 67 68 69 70 71 72 73 74 75 76
            // Generate the PR trigger phrase for this job.
            String triggerKeyword = '';
            switch (buildTarget) {
              case 'unit32':
                triggerKeyword =  '(unit|unit32|unit\\W+32)';
                break;
              case 'unit64':
                triggerKeyword = '(unit|unit64|unit\\W+64)';
                break;
            }
            String triggerPhrase = generateTriggerPhrase(jobName, opsys, triggerKeyword);
J
Jared Parsons 已提交
77
            Boolean triggerPhraseOnly = false;
78

79 80 81 82
            switch (opsys) {
              case 'win':
                myJob.with {
                  steps {
83
                    batchFile("""set TEMP=%WORKSPACE%\\Binaries\\Temp
84
mkdir %TEMP%
85
set TMP=%TEMP%
L
Larry Golding 已提交
86
.\\cibuild.cmd ${(configuration == 'dbg') ? '/debug' : '/release'} ${(buildTarget == 'unit32') ? '/test32' : '/test64'}""")
87
                  }
88
                }
89
                Utilities.setMachineAffinity(myJob, 'Windows_NT', 'latest-or-auto')
90 91 92 93
                break;
              case 'linux':
                myJob.with {
                  steps {
94
                    shell("./cibuild.sh --nocache --debug")
95
                  }
96
                }
M
Matt Mitchell 已提交
97
                Utilities.setMachineAffinity(myJob, 'Ubuntu14.04', 'latest-or-auto')
98 99 100 101 102
                break;
              case 'mac':
                myJob.with {
                  label('mac-roslyn')
                  steps {
103
                    shell("./cibuild.sh --nocache --debug")
104 105
                  }
                }
J
Jared Parsons 已提交
106
                triggerPhraseOnly = true;
107
                break;
108 109
            }

110
            Utilities.addXUnitDotNETResults(myJob, '**/xUnitResults/*.xml')
111
            addRoslynJob(myJob, jobName, branchName, triggerPhrase, triggerPhraseOnly)
112 113 114 115 116
          }
        }
      }
    }
  }
117

J
Jared Parsons 已提交
118 119 120 121
  def determinismJobName = "roslyn_${jobBranchName}_determinism"
  def determinismJob = job(determinismJobName) {
    description('')
  }
122

J
Jared Parsons 已提交
123 124 125 126
  determinismJob.with {
    label('windows-roslyn')
    steps {
      batchFile("""set TEMP=%WORKSPACE%\\Binaries\\Temp
127 128 129 130
mkdir %TEMP%
set TMP=%TEMP%
.\\cibuild.cmd /testDeterminism""")
    }
131
  }
J
Jared Parsons 已提交
132

133
  Utilities.setMachineAffinity(determinismJob, 'Windows_NT', 'latest-or-auto')
134
  addRoslynJob(determinismJob, determinismJobName, branchName,  "(?i).*test\\W+determinism.*", true);
135
}
136