2015-11-16 11:21:57 -08:00
// 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.
2015-10-08 16:07:36 -07:00
// Import the utility functionality.
2018-05-17 13:29:46 -07:00
import jobs.generation.ArchivalSettings ;
2015-10-08 16:07:36 -07:00
import jobs.generation.Utilities ;
2015-12-03 08:37:04 -08:00
def project = GithubProject
2016-02-12 09:11:20 -08:00
def branch = GithubBranchName
2016-03-11 14:32:36 -08:00
def isPR = true
2015-10-08 16:07:36 -07:00
2018-05-02 10:05:32 -07:00
def platformList = [
2018-07-12 16:20:39 -07:00
'AllLinux:x64:Release' ,
2018-05-02 10:05:32 -07:00
'CentOS7.1:x64:Debug' ,
'Debian8.2:x64:Debug' ,
'fedora.27:x64:Debug' ,
'Linux:arm:Debug' ,
'Linux:arm64:Debug' ,
'Linux-musl:x64:Debug' ,
'Linux:x64:Release' ,
2018-07-31 15:06:02 -07:00
'Linux_NoSuffix:arm:Release' ,
'Linux_NoSuffix:x64:Release' ,
'opensuse.42.3:x64:Debug' ,
2018-05-02 10:05:32 -07:00
'OSX10.12:x64:Release' ,
'RHEL6:x64:Debug' ,
'RHEL7.2:x64:Release' ,
'Ubuntu:x64:Release' ,
'Ubuntu16.04:x64:Debug' ,
'ubuntu.18.04:x64:Debug' ,
'Windows_NT:x64:Release' ,
'Windows_NT:x86:Debug' ,
2018-07-31 15:06:02 -07:00
'Windows_NT_ES:x64:Debug' ,
'Windows_NT_NoSuffix:x64:Release'
2018-05-02 10:05:32 -07:00
]
2015-10-08 16:07:36 -07:00
2016-03-11 14:32:36 -08:00
def static getBuildJobName ( def configuration , def os , def architecture ) {
return configuration . toLowerCase ( ) + '_' + os . toLowerCase ( ) + '_' + architecture . toLowerCase ( )
2015-10-08 16:07:36 -07:00
}
2016-03-11 14:32:36 -08:00
platformList . each { platform - >
// Calculate names
def ( os , architecture , configuration ) = platform . tokenize ( ':' )
2017-03-09 09:02:14 -10:00
def osUsedForMachineAffinity = os ;
2018-03-27 16:14:03 -07:00
def osVersionUsedForMachineAffinity = 'latest-or-auto' ;
2015-12-03 08:57:28 -08:00
2016-03-11 14:32:36 -08:00
// Calculate job name
def jobName = getBuildJobName ( configuration , os , architecture )
2018-07-31 15:06:02 -07:00
def baseBatchBuildCommand = ".\\build.cmd -Configuration ${configuration} -Architecture ${architecture} -Targets Default" ;
def baseShellBuildCommand = "./build.sh --skip-prereqs --configuration ${configuration} --targets Default" ;
2015-10-22 17:41:39 -07:00
2016-03-11 14:32:36 -08:00
// Calculate the build command
2018-07-31 15:06:02 -07:00
if ( os . startsWith ( "Windows_NT" ) ) {
2017-09-06 16:12:31 -07:00
osUsedForMachineAffinity = 'Windows_NT'
2018-07-31 15:06:02 -07:00
buildCommand = "${baseBatchBuildCommand}"
if ( os = = 'Windows_NT_ES' ) {
buildCommand = "" "
2017-09-06 16:12:31 -07:00
set DOTNET_CLI_UI_LANGUAGE = es
2018-07-31 15:06:02 -07:00
$ { buildCommand }
"" "
}
else if ( os = = 'Windows_NT_NoSuffix' ) {
buildCommand = "" "
set DropSuffix = true
$ { buildCommand }
2017-09-06 16:12:31 -07:00
"" "
2018-07-31 15:06:02 -07:00
}
2017-09-06 16:12:31 -07:00
}
2018-07-31 15:06:02 -07:00
else if ( os = = 'Windows_2016' ) {
buildCommand = "${baseBatchBuildCommand} -RunInstallerTestsInDocker"
2016-03-11 14:32:36 -08:00
}
2018-07-31 15:06:02 -07:00
else if ( os . startsWith ( "Linux" ) ) {
2017-03-09 09:02:14 -10:00
osUsedForMachineAffinity = 'Ubuntu16.04' ;
2018-07-31 15:06:02 -07:00
if ( os = = 'Linux-musl' ) {
buildCommand = "${baseShellBuildCommand} --runtime-id linux-musl-x64 --docker alpine.3.6"
2018-03-14 19:04:25 -07:00
}
2018-07-31 15:06:02 -07:00
else
{
buildCommand = "${baseShellBuildCommand} --linux-portable"
if ( ( architecture = = 'arm' ) | | ( architecture = = 'arm64' ) ) {
buildCommand = "${buildCommand} --architecture ${architecture} /p:CLIBUILD_SKIP_TESTS=true"
}
if ( os = = 'Linux_NoSuffix' ) {
buildCommand = "" "
export DropSuffix = true
$ { buildCommand }
"" "
}
2018-03-14 19:04:25 -07:00
}
2017-03-09 09:02:14 -10:00
}
2018-07-31 15:06:02 -07:00
else if ( os = = 'Ubuntu' ) {
buildCommand = "${baseShellBuildCommand} --docker ubuntu.14.04"
2017-10-10 18:08:06 +02:00
}
2018-07-31 15:06:02 -07:00
else if ( os = = 'RHEL6' ) {
2017-11-29 17:03:48 +01:00
osUsedForMachineAffinity = 'Ubuntu16.04' ;
2018-07-31 15:06:02 -07:00
buildCommand = "${baseShellBuildCommand} --runtime-id rhel.6-x64 --docker rhel.6"
2017-11-29 17:03:48 +01:00
}
2018-07-31 15:06:02 -07:00
else if ( os = = 'ubuntu.18.04' | | os = = 'fedora.27' | | os = = 'opensuse.42.3' ) {
2018-03-27 16:14:03 -07:00
osUsedForMachineAffinity = 'Ubuntu16.04'
osVersionUsedForMachineAffinity = 'latest-docker'
2018-07-31 15:06:02 -07:00
buildCommand = "${baseShellBuildCommand} --docker ${os} --linux-portable"
2018-03-27 16:14:03 -07:00
}
2018-07-12 16:20:39 -07:00
else if ( os = = 'AllLinux' ) {
osUsedForMachineAffinity = 'Ubuntu16.04'
2018-07-31 16:25:02 -07:00
buildCommand = "${baseShellBuildCommand} --skip-prereqs --configuration ${configuration} --targets Default /t:BuildAndPublishAllLinuxDistrosNativeInstallers"
2018-07-12 16:20:39 -07:00
}
2016-03-11 14:32:36 -08:00
else {
2018-07-31 15:06:02 -07:00
buildCommand = "${baseShellBuildCommand}"
2016-03-11 14:32:36 -08:00
}
2015-10-21 11:24:23 -07:00
2016-03-11 14:32:36 -08:00
def newJob = job ( Utilities . getFullJobName ( project , jobName , isPR ) ) {
// Set the label.
steps {
2017-09-06 16:12:31 -07:00
if ( osUsedForMachineAffinity = = 'Windows_NT' | | osUsedForMachineAffinity = = 'Windows_2016' ) {
2016-03-11 14:32:36 -08:00
// Batch
batchFile ( buildCommand )
2015-12-03 08:57:28 -08:00
}
else {
2016-03-11 14:32:36 -08:00
// Shell
shell ( buildCommand )
2015-12-03 08:57:28 -08:00
}
}
}
2016-03-11 14:32:36 -08:00
2018-03-27 16:14:03 -07:00
Utilities . setMachineAffinity ( newJob , osUsedForMachineAffinity , osVersionUsedForMachineAffinity )
2016-03-11 14:32:36 -08:00
Utilities . standardJobSetup ( newJob , project , isPR , "*/${branch}" )
2018-07-12 16:20:39 -07:00
// ARM and AllLinux CI runs are build only.
if ( ( architecture ! = 'arm' ) & & ( architecture ! = 'arm64' ) & & ( os ! = 'AllLinux' ) ) {
2018-03-15 12:30:11 -07:00
Utilities . addMSTestResults ( newJob , '**/*.trx' )
}
2016-03-11 14:32:36 -08:00
Utilities . addGithubPRTriggerForBranch ( newJob , branch , "${os} ${architecture} ${configuration} Build" )
2018-05-17 13:29:46 -07:00
2018-07-31 15:06:02 -07:00
def archiveSettings = new ArchivalSettings ( )
archiveSettings . addFiles ( "test/**/*.trx" )
archiveSettings . addFiles ( "*.binlog" )
archiveSettings . setFailIfNothingArchived ( )
archiveSettings . setArchiveOnFailure ( )
2018-05-17 13:29:46 -07:00
Utilities . addArchival ( newJob , archiveSettings )
2016-02-16 12:04:13 -08:00
}
2016-03-11 14:32:36 -08:00
2017-03-30 19:40:03 +09:00
// 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.
2017-05-15 11:47:42 -07:00
Utilities . addCROSSCheck ( this , project , branch )