netci.groovy 5.8 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
static void addEmailPublisher(def myJob) {
  myJob.with {
    publishers {
T
Ty Overby 已提交
12 13 14 15
      extendedEmail('mlinfraswat@microsoft.com', '$DEFAULT_SUBJECT', '$DEFAULT_CONTENT') {
	// trigger(trigger name, subject, body, recipient list, send to developers, send to requester, include culprits, send to recipient list)
        trigger('Aborted', '$PROJECT_DEFAULT_SUBJECT', '$PROJECT_DEFAULT_CONTENT', null, false, false, false, true)
        trigger('Failure', '$PROJECT_DEFAULT_SUBJECT', '$PROJECT_DEFAULT_CONTENT', null, false, false, false, true)
16 17 18 19 20
      }
    }
  }
}

21 22 23 24 25 26 27 28 29 30 31 32
// Calls a web hook on Jenkins build events.  Allows our build monitoring jobs to be push notified
// vs. polling
static void addBuildEventWebHook(def myJob) {
  myJob.with {
    notifications {
      endpoint('https://jaredpar.azurewebsites.net/api/BuildEvent?code=tts2pvyelahoiliwu7lo6flxr8ps9kaip4hyr4m0ofa3o3l3di77tzcdpk22kf9gex5m6cbrcnmi') {
        event('all')
      }
    }
  }   
}

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

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

44
  // Create the standard job.  This will setup parameter, SCM, timeout, etc ...
45
  def projectName = 'dotnet/roslyn'
J
Jared Parsons 已提交
46
  def isPr = branchName == 'prtest'
47
  def defaultBranch = "*/${branchName}"
48
  Utilities.standardJobSetup(myJob, projectName, isPr, defaultBranch)
49 50

  // Need to setup the triggers for the job
J
Jared Parsons 已提交
51
  if (isPr) {
J
Jared Parsons 已提交
52 53
    def contextName = jobName.replace('_', '/').substring(7)
    Utilities.addGithubPRTrigger(myJob, contextName, triggerPhrase, triggerPhraseOnly)
54
  } else {
55
    Utilities.addGithubPushTrigger(myJob)
56 57
    addEmailPublisher(myJob)
  }
58 59

  addBuildEventWebHook(myJob)
60 61
}

A
Artur Spychaj 已提交
62
def branchNames = []
63
['master', 'future', 'stabilization', 'future-stabilization', 'hotfixes', 'prtest', 'microupdate'].each { branchName ->
A
Artur Spychaj 已提交
64 65 66 67 68
  def shortBranchName = branchName.substring(0, 6)
  def jobBranchName = shortBranchName in branchNames ? branchName : shortBranchName
  branchNames << jobBranchName

  // folder("${jobBranchName}")
69
  ['win', 'linux', 'mac'].each { opsys ->
A
Artur Spychaj 已提交
70
    // folder("${jobBranchName}/${opsys.substring(0, 3)}")
71 72
    ['dbg', 'rel'].each { configuration ->
      if ((configuration == 'dbg') || ((branchName != 'prtest') && (opsys == 'win'))) {
A
Artur Spychaj 已提交
73
        // folder("${jobBranchName}/${opsys.substring(0, 3)}/${configuration}")
74 75
        ['unit32', 'unit64'].each { buildTarget ->
          if ((opsys == 'win') || (buildTarget == 'unit32')) {
A
Artur Spychaj 已提交
76
            def jobName = "roslyn_${jobBranchName}_${opsys.substring(0, 3)}_${configuration}_${buildTarget}"
77 78 79 80
            def myJob = job(jobName) {
              description('')
            }

81 82 83 84 85 86 87 88 89 90 91
            // 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 已提交
92
            Boolean triggerPhraseOnly = false;
93

94 95 96 97
            switch (opsys) {
              case 'win':
                myJob.with {
                  steps {
98
                    batchFile("""set TEMP=%WORKSPACE%\\Binaries\\Temp
99
mkdir %TEMP%
100
set TMP=%TEMP%
L
Larry Golding 已提交
101
.\\cibuild.cmd ${(configuration == 'dbg') ? '/debug' : '/release'} ${(buildTarget == 'unit32') ? '/test32' : '/test64'}""")
102
                  }
103
                }
104
                Utilities.setMachineAffinity(myJob, 'Windows_NT', 'latest-or-auto')
105 106 107 108
                break;
              case 'linux':
                myJob.with {
                  steps {
109
                    shell("./cibuild.sh --nocache --debug")
110
                  }
111
                }
M
Matt Mitchell 已提交
112
                Utilities.setMachineAffinity(myJob, 'Ubuntu14.04', 'latest-or-auto')
113 114 115 116 117
                break;
              case 'mac':
                myJob.with {
                  label('mac-roslyn')
                  steps {
118
                    shell("./cibuild.sh --nocache --debug")
119 120
                  }
                }
J
Jared Parsons 已提交
121
                triggerPhraseOnly = true;
122
                break;
123 124
            }

125
            Utilities.addXUnitDotNETResults(myJob, '**/xUnitResults/*.xml')
126
            addRoslynJob(myJob, jobName, branchName, triggerPhrase, triggerPhraseOnly)
127 128 129 130 131
          }
        }
      }
    }
  }
132

J
Jared Parsons 已提交
133 134 135 136
  def determinismJobName = "roslyn_${jobBranchName}_determinism"
  def determinismJob = job(determinismJobName) {
    description('')
  }
137

J
Jared Parsons 已提交
138 139 140 141
  determinismJob.with {
    label('windows-roslyn')
    steps {
      batchFile("""set TEMP=%WORKSPACE%\\Binaries\\Temp
142 143 144 145
mkdir %TEMP%
set TMP=%TEMP%
.\\cibuild.cmd /testDeterminism""")
    }
146
  }
J
Jared Parsons 已提交
147

148
  Utilities.setMachineAffinity(determinismJob, 'Windows_NT', 'latest-or-auto')
149
  addRoslynJob(determinismJob, determinismJobName, branchName,  "(?i).*test\\W+determinism.*", true);
150
}
151