forked from dotnet/project-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnetci.groovy
228 lines (193 loc) · 9.03 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
// Import the utility functionality.
import jobs.generation.*;
// Defines a the new of the repo, used elsewhere in the file
def project = GithubProject
def branch = GithubBranchName
// Generate the builds for debug and release, commit and PRJob
[true, false].each { isPR -> // Defines a closure over true and false, value assigned to isPR
['Debug', 'Release'].each { configuration ->
def newJobName = Utilities.getFullJobName(project, "windows_${configuration.toLowerCase()}", isPR)
def newJob = job(newJobName) {
// This opens the set of build steps that will be run.
steps {
// Indicates that a batch script should be run with the build string (see above)
// Also available is:
// shell (for unix scripting)
batchFile("""
echo *** Build Roslyn Project System ***
SET VS150COMNTOOLS=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\
SET VSSDK150Install=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\VSSDK\\
SET VSSDKInstall=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\VSSDK\\
build.cmd /no-node-reuse /no-deploy-extension /${configuration.toLowerCase()}
""")
}
}
def archiveSettings = new ArchivalSettings()
archiveSettings.addFiles("bin/**/*")
archiveSettings.excludeFiles("bin/obj/*")
archiveSettings.setFailIfNothingArchived()
archiveSettings.setArchiveOnFailure()
Utilities.addArchival(newJob, archiveSettings)
Utilities.setMachineAffinity(newJob, 'Windows_NT', 'latest-or-auto-dev15-0')
Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
Utilities.addXUnitDotNETResults(newJob, "**/*TestResults.xml")
if (isPR) {
Utilities.addGithubPRTriggerForBranch(newJob, branch, "Windows ${configuration}")
}
else {
Utilities.addGithubPushTrigger(newJob)
}
}
}
// Add VSI jobs.
// Generate the builds for commit and PRJob
[true, false].each { isPR -> // Defines a closure over true and false, value assigned to isPR
def newVsiJobName = Utilities.getFullJobName(project, "vsi", isPR)
def newVsiJob = job(newVsiJobName) {
description('')
// This opens the set of build steps that will be run.
steps {
// Build roslyn-project-system repo - we also need to set certain environment variables for building the repo with VS15 toolset.
batchFile("""
echo *** Build Roslyn Project System ***
rmdir /S /Q %USERPROFILE%\\.nuget\\packages\\microbuild.plugins.swixbuild
SET VS150COMNTOOLS=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\
SET VSSDK150Install=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild\\Microsoft\\VisualStudio\\v15.0\\VSSDK\\
SET VSSDKInstall=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild\\Microsoft\\VisualStudio\\v15.0\\VSSDK\\
build.cmd /no-node-reuse /release /skiptests
""")
// Patch all the MSBuild xaml and targets files from the current roslyn-project-system commit into VS install.
batchFile("""
echo *** Patch the MSBuild xaml and targets ***
SET VS_MSBUILD_MANAGED=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild\\Microsoft\\VisualStudio\\Managed
mkdir backup
xcopy /SIY "%VS_MSBUILD_MANAGED%" .\\backup\\Managed
xcopy /SIY .\\src\\Targets\\*.targets "%VS_MSBUILD_MANAGED%"
xcopy /SIY .\\bin\\Release\\Rules\\*.xaml "%VS_MSBUILD_MANAGED%"
""")
// Restore roslyn nuget packages
batchFile("""
echo *** Restore Roslyn ***
pushd %WORKSPACE%\\roslyn
Restore.cmd
""")
// Build the SDK and install .NET Core Templates.
batchFile("""
echo *** Build the SDK and install .NET Core Templates ***
SET VS150COMNTOOLS=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\
SET DeveloperCommandPrompt=%VS150COMNTOOLS%\\VsMSBuildCmd.bat
echo *** Call VsMSBuildCmd.bat
call "%DeveloperCommandPrompt%" || goto :BuildFailed "VsMSBuildCmd.bat"
SET VSSDK150Install=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild\\Microsoft\\VisualStudio\\v15.0\\VSSDK\\
SET VSSDKInstall=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild\\Microsoft\\VisualStudio\\v15.0\\VSSDK\\
SET MSBUILDEXE=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild\\15.0\\Bin\\MSBuild.exe
pushd %WORKSPACE%\\sdk
echo *** Build SDK
call build.cmd -Configuration release -SkipTests || goto :BuildFailed "SDK"
"%MSBUILDEXE%" /m /v:m /p:DeployExtension=True;VSSDKTargetPlatformRegRootSuffix=RoslynDev;Configuration=Release sdk-templates.sln
exit /b 0
:BuildFailed
echo %1 - Build failed with ERRORLEVEL %ERRORLEVEL%
exit /b 1
""")
// Build roslyn and run netcore VSI tests.
batchFile("""
echo *** Build Roslyn Internal and Test Roslyn Project System ***
SET VS150COMNTOOLS=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\
SET VSSDK150Install=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild\\Microsoft\\VisualStudio\\v15.0\\VSSDK\\
SET VSSDKInstall=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild\\Microsoft\\VisualStudio\\v15.0\\VSSDK\\
pushd %WORKSPACE%\\roslyn\\build\\scripts\\
set TEMP=%WORKSPACE%\\roslyn\\Binaries\\Temp
mkdir %TEMP%
set TMP=%TEMP%
cibuild.cmd /release /testVsiNetCore
""")
// Revert patched targets and rules from backup.
batchFile("""
echo *** Revert the MSBuild xaml and targets ***
SET VS_MSBUILD_MANAGED=%ProgramFiles(x86)%\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild\\Microsoft\\VisualStudio\\Managed
del /SQ "%VS_MSBUILD_MANAGED%\\"
xcopy /SIY .\\backup\\Managed "%VS_MSBUILD_MANAGED%"
rmdir /S /Q backup
""")
}
}
addVsiArchive(newVsiJob)
Utilities.setMachineAffinity(newVsiJob, 'Windows_NT', 'latest-or-auto-dev15-0-internal')
Utilities.standardJobSetup(newVsiJob, project, isPR, "*/${branch}")
// ISSUE: Temporary until a full builder for source control is available.
addVsiMultiScm(newVsiJob, project, isPR)
if (isPR) {
def triggerPhrase = generateTriggerPhrase(newVsiJobName, "vsi")
Utilities.addGithubPRTriggerForBranch(newVsiJob, branch, newVsiJobName, triggerPhrase, /*triggerPhraseOnly*/ true)
} else {
Utilities.addGithubPushTrigger(newVsiJob)
}
Utilities.addXUnitDotNETResults(newVsiJob, '**/xUnitResults/*.xml')
}
// Archive VSI artifacts.
static void addVsiArchive(def myJob) {
def archiveSettings = new ArchivalSettings()
archiveSettings.addFiles('roslyn/Binaries/**/*.pdb')
archiveSettings.addFiles('roslyn/Binaries/**/*.xml')
archiveSettings.addFiles('roslyn/Binaries/**/*.log')
archiveSettings.addFiles('roslyn/Binaries/**/*.zip')
archiveSettings.addFiles('roslyn/Binaries/**/*.png')
archiveSettings.addFiles('roslyn/Binaries/**/*.xml')
archiveSettings.excludeFiles('roslyn/Binaries/Obj/**')
archiveSettings.excludeFiles('roslyn/Binaries/Bootstrap/**')
archiveSettings.setArchiveOnFailure()
archiveSettings.setFailIfNothingArchived()
Utilities.addArchival(myJob, archiveSettings)
}
// ISSUE: Temporary until a full builder for multi-scm source control is available.
// Replace the scm settings with a multiScm setup. Note: for PR jobs; explicitly set the refspec
static void addVsiMultiScm(def myJob, def project, def isPR) {
myJob.with {
multiscm {
git {
remote {
// Use the input project
github(project)
if (isPR) {
// Set the refspec
refspec('${GitRefSpec}')
}
}
// Pull from the desired branch input branch passed as a parameter (set up by standardJobSetup)
branch('${GitBranchOrCommit}')
}
git {
remote {
url('/~https://github.com/dotnet/sdk')
}
extensions {
relativeTargetDirectory('sdk')
}
// pull in a specific LKG commit from master.
branch('*/master')
}
git {
remote {
url('/~https://github.com/dotnet/roslyn')
}
extensions {
relativeTargetDirectory('roslyn')
}
branch('*/master')
}
}
}
}
// END ISSUE
static String generateTriggerPhrase(String jobName, String triggerPhraseExtra) {
def triggerCore = "all|${jobName}"
if (triggerPhraseExtra) {
triggerCore = "${triggerCore}|${triggerPhraseExtra}"
}
return "(?i).*test\\W+(${triggerCore})\\W+please.*";
}
// Make the call to generate the help job
Utilities.createHelperJob(this, project, branch,
"Welcome to the ${project} Repository", // This is prepended to the help message
"Have a nice day!") // This is appended to the help message. You might put known issues here.