forked from dotnet/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netci.groovy
96 lines (78 loc) · 2.99 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
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Import the utility functionality.
import jobs.generation.Utilities;
import jobs.generation.InternalUtilities;
def project = 'dotnet/cli'
def osList = ['Ubuntu', 'OSX', 'Windows_NT']
def machineLabelMap = ['Ubuntu':'ubuntu-doc',
'OSX':'mac',
'Windows_NT':'windows']
def static getBuildJobName(def configuration, def os) {
return configuration.toLowerCase() + '_' + os.toLowerCase()
}
['Debug', 'Release'].each { configuration ->
osList.each { os ->
// Calculate names
def lowerConfiguration = configuration.toLowerCase()
// Calculate job name
def jobName = getBuildJobName(configuration, os)
def buildCommand = '';
def postBuildCommand = '';
// Calculate the build command
if (os == 'Windows_NT') {
buildCommand = ".\\scripts\\ci_build.cmd ${lowerConfiguration}"
}
else {
buildCommand = "./scripts/ci_build.sh ${lowerConfiguration}"
}
// Create the new job
def newCommitJob = job(InternalUtilities.getFullJobName(project, jobName, false)) {
// Set the label.
label(machineLabelMap[os])
steps {
if (os == 'Windows_NT') {
// Batch
batchFile(buildCommand)
}
else {
// Shell
shell(buildCommand)
}
}
}
InternalUtilities.addPrivatePermissions(newCommitJob)
InternalUtilities.addPrivateScm(newCommitJob, project)
Utilities.addStandardOptions(newCommitJob)
Utilities.addStandardNonPRParameters(newCommitJob)
Utilities.addGithubPushTrigger(newCommitJob)
def newPRJob = job(InternalUtilities.getFullJobName(project, jobName, true)) {
// Set the label.
label(machineLabelMap[os])
steps {
if (os == 'Windows_NT') {
// Batch
batchFile(buildCommand)
}
else {
// Shell
shell(buildCommand)
// Post Build Cleanup
publishers {
postBuildScripts {
steps {
shell(postBuildCommand)
}
onlyIfBuildSucceeds(false)
}
}
}
}
}
InternalUtilities.addPrivatePermissions(newPRJob)
InternalUtilities.addPrivatePRTestSCM(newPRJob, project)
Utilities.addStandardOptions(newPRJob)
Utilities.addStandardPRParameters(newPRJob, project)
Utilities.addGithubPRTrigger(newPRJob, "${os} ${configuration} Build")
}
}