forked from dotnet/symstore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netci.groovy
198 lines (165 loc) · 5.91 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// 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 opsysName, def configName, def testName) {
return "${opsysName}_${configName}_${testName}"
}
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 testName) {
def prContext = "prtest/${jobName.replace('_', '/')}"
def triggerPhrase = "(?i).*test\\W+${prContext}.*"
def triggerOnPhraseOnly = (testName != 'build')
Utilities.addGithubPRTriggerForBranch(job, branchName, prContext, triggerPhrase, triggerOnPhraseOnly)
}
static addGithubPRCommitStatusForBranch(def job, def branchName, def jobName, def testName) {
def prContext = "prtest/${jobName.replace('_', '/')}"
job.with {
wrappers {
downstreamCommitStatus {
context(prContext)
}
}
}
}
static addXUnitDotNETResults(def job, def configName) {
def resultFilePattern = "**/artifacts/${configName}/log/xUnit-*.xml"
def skipIfNoTestFiles = false
Utilities.addXUnitDotNETResults(job, resultFilePattern, skipIfNoTestFiles)
}
static addExtendedEmailPublisher(def job) {
job.with {
publishers {
extendedEmail {
defaultContent('$DEFAULT_CONTENT')
defaultSubject('$DEFAULT_SUBJECT')
recipientList('$DEFAULT_RECIPIENTS, cc:[email protected]')
triggers {
aborted {
content('$PROJECT_DEFAULT_CONTENT')
sendTo {
culprits()
developers()
recipientList()
requester()
}
subject('$PROJECT_DEFAULT_SUBJECT')
}
failure {
content('$PROJECT_DEFAULT_CONTENT')
sendTo {
culprits()
developers()
recipientList()
requester()
}
subject('$PROJECT_DEFAULT_SUBJECT')
}
}
}
}
}
}
static addBuildSteps(def job, def projectName, def opsysName, def configName, def isPR) {
def unit32JobName = getJobName(opsysName, configName, 'unit32')
def unit32FullJobName = Utilities.getFullJobName(projectName, unit32JobName, isPR)
def unit64JobName = getJobName(opsysName, configName, 'unit64')
def unit64FullJobName = Utilities.getFullJobName(projectName, unit64JobName, isPR)
def coreJobName = getJobName(opsysName, configName, 'core')
def coreFullJobName = Utilities.getFullJobName(projectName, coreJobName, isPR)
def downstreamFullJobNames = "${unit32FullJobName}, ${unit64FullJobName}, ${coreFullJobName}"
def officialSwitch = ''
if (!isPR) {
officialSwitch = '-Official'
}
job.with {
steps {
batchFile("""set TEMP=%WORKSPACE%\\artifacts\\${configName}\\tmp
mkdir %TEMP%
set TMP=%TEMP%
.\\Build.cmd -Configuration ${configName} -msbuildVersion '14.0' ${officialSwitch} -SkipDeploy -SkipTest
""")
publishers {
downstreamParameterized {
trigger(downstreamFullJobNames) {
condition('UNSTABLE_OR_BETTER')
parameters {
currentBuild()
gitRevision()
}
}
}
}
}
}
}
static addTestSteps(def job, def projectName, def opsysName, def configName, def testName, def isPR, def filesToArchive, def filesToExclude) {
def buildJobName = getJobName(opsysName, configName, 'build')
def buildFullJobName = Utilities.getFullJobName(projectName, buildJobName, isPR)
def officialSwitch = ''
if (!isPR) {
officialSwitch = '-Official'
}
job.with {
steps {
copyArtifacts(buildFullJobName) {
includePatterns(filesToArchive)
excludePatterns(filesToExclude)
buildSelector {
upstreamBuild {
fallbackToLastSuccessful(false)
}
}
}
batchFile("""set TEMP=%WORKSPACE%\\artifacts\\${configName}\\tmp
mkdir %TEMP%
set TMP=%TEMP%
.\\Build.cmd -Configuration ${configName} -msbuildVersion '14.0' ${officialSwitch} -SkipBuild ${testName == 'unit32' ? '-SkipTest64 -SkipTestCore' : (testName == 'core' ? '-SkipTest32 -SkipTest64' : '-SkipTest32 -SkipTestCore')}
""")
}
}
}
[true, false].each { isPR ->
['windows'].each { opsysName ->
['debug', 'release'].each { configName ->
['build', 'unit32', 'unit64', 'core'].each { testName ->
def projectName = GithubProject
def branchName = GithubBranchName
def filesToArchive = "**/artifacts/${configName}/**"
def filesToExclude = "**/artifacts/${configName}/obj/**"
def jobName = getJobName(opsysName, configName, testName)
def fullJobName = Utilities.getFullJobName(projectName, jobName, isPR)
def myJob = job(fullJobName)
Utilities.standardJobSetup(myJob, projectName, isPR, "*/${branchName}")
if (testName == 'build') {
if (isPR) {
addGithubPRTriggerForBranch(myJob, branchName, jobName, testName)
} else {
Utilities.addGithubPushTrigger(myJob)
}
}
else {
if (isPR) {
addGithubPRCommitStatusForBranch(myJob, branchName, jobName, testName)
}
}
addArchival(myJob, filesToArchive, filesToExclude)
if (testName != 'build') {
addXUnitDotNETResults(myJob, configName)
}
Utilities.setMachineAffinity(myJob, 'Windows_NT', 'latest-or-auto')
if (!isPR) {
addExtendedEmailPublisher(myJob)
}
if (testName == 'build') {
addBuildSteps(myJob, projectName, opsysName, configName, isPR)
} else {
addTestSteps(myJob, projectName, opsysName, configName, testName, isPR, filesToArchive, filesToExclude)
}
}
}
}
}