forked from dotnet/arcade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netci.groovy
80 lines (61 loc) · 2.55 KB
/
netci.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Groovy Script: http://www.groovy-lang.org/syntax.html
// Jenkins DSL: https://github.com/jenkinsci/job-dsl-plugin/wiki
import jobs.generation.Utilities;
static getJobName(def os, def configName) {
return "${os}_${configName}"
}
static addArchival(def job, def filesToArchive, def filesToExclude) {
def doNotFailIfNothingArchived = false
def archiveOnlyIfSuccessful = false
Utilities.addArchival(job, filesToArchive, filesToExclude, doNotFailIfNothingArchived, archiveOnlyIfSuccessful)
}
static addGithubPRTriggerForBranch(def job, def branchName, def jobName) {
def prContext = "prtest/${jobName.replace('_', '/')}"
def triggerPhrase = "(?i)^\\s*(@?dotnet-bot\\s+)?(re)?test\\s+(${prContext})(\\s+please)?\\s*\$"
def triggerOnPhraseOnly = false
Utilities.addGithubPRTriggerForBranch(job, branchName, prContext, triggerPhrase, triggerOnPhraseOnly)
}
static addXUnitDotNETResults(def job, def configName) {
def resultFilePattern = "**/artifacts/TestResults/${configName}/*.xml"
def skipIfNoTestFiles = false
Utilities.addXUnitDotNETResults(job, resultFilePattern, skipIfNoTestFiles)
}
static addBuildSteps(def job, def projectName, def os, def configName, def isPR) {
def buildJobName = getJobName(os, configName)
def buildFullJobName = Utilities.getFullJobName(projectName, buildJobName, isPR)
job.with {
steps {
if(os == "Windows_NT") {
batchFile(".\\eng\\common\\CIBuild.cmd -configuration ${configName} -prepareMachine")
}
else {
shell("./eng/common/cibuild.sh --configuration ${configName} --preparemachine")
}
}
}
}
[true, false].each { isPR ->
['Ubuntu16.04', 'Windows_NT'].each { os ->
['Debug', 'Release'].each { configName ->
def projectName = GithubProject
def branchName = GithubBranchName
def osBase = os
def machineAffinity = 'latest-or-auto'
def filesToArchive = "**/artifacts/**"
def filesToExclude = "**/artifacts/obj/**"
def jobName = getJobName(os, configName)
def fullJobName = Utilities.getFullJobName(projectName, jobName, isPR)
def myJob = job(fullJobName)
Utilities.standardJobSetup(myJob, projectName, isPR, "*/${branchName}")
if (isPR) {
addGithubPRTriggerForBranch(myJob, branchName, jobName)
} else {
Utilities.addGithubPushTrigger(myJob)
}
addArchival(myJob, filesToArchive, filesToExclude)
addXUnitDotNETResults(myJob, configName)
Utilities.setMachineAffinity(myJob, os, machineAffinity)
addBuildSteps(myJob, projectName, os, configName, isPR)
}
}
}