Update Tizen CI docker image
[platform/upstream/dotnet/runtime.git] / src / installer / netci.groovy
1 // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4 // Import the utility functionality.
5
6 import jobs.generation.Utilities;
7 import jobs.generation.ArchivalSettings;
8
9 def project = GithubProject
10 def branch = GithubBranchName
11 def isPR = true
12
13 def platformList = ['Linux:x64:Release', 'Linux:arm:Release', 'Linux:arm64:Release', 'OSX:x64:Release', 'Windows_NT:x64:Release', 'Windows_NT:x86:Debug', 'Windows_NT:arm:Debug', 'Tizen:armel:Release']
14
15 def static getBuildJobName(def configuration, def os, def architecture) {
16     return configuration.toLowerCase() + '_' + os.toLowerCase() + '_' + architecture.toLowerCase()
17 }
18
19 platformList.each { platform ->
20     // Calculate names
21     def (os, architecture, configuration) = platform.tokenize(':')
22
23     // Calculate the job name
24     def jobName = getBuildJobName(configuration, os, architecture)
25     def buildCommand = '';
26     def osForGHTrigger = os
27     def version = "latest-or-auto"
28     def dockerRepository = "microsoft/dotnet-buildtools-prereqs"
29     def dockerContainer = ''
30     def dockerWorkingDirectory = "/src/core-setup"
31     def dockerCommand = ''
32     def crossbuildargs = ''
33     def buildArgs = "-ConfigurationGroup=${configuration} -TargetArchitecture=${architecture}"
34
35     if (os != 'Windows_NT' && configuration == 'Release') {
36         buildArgs += " -strip-symbols"
37     }
38
39     // Calculate build command
40     if (os == 'Windows_NT') {
41         buildCommand = ".\\build.cmd ${buildArgs}"
42         if ((architecture == 'arm' || architecture == 'arm64')) {
43             buildCommand += " -SkipTests=true"
44         }
45     }
46     else if (os == 'Tizen') {
47         dockerRepository = "gbalykov/dotnet-buildtools-prereqs"
48         dockerContainer = "ubuntu-16.04-cross-e435274-20180426002255-tizen-rootfs-4.0m2"
49
50         dockerCommand = "docker run -e ROOTFS_DIR=/crossrootfs/${architecture}.tizen.build --name ${dockerContainer} --rm -v \${WORKSPACE}:${dockerWorkingDirectory} -w=${dockerWorkingDirectory} ${dockerRepository}:${dockerContainer}"
51         buildArgs += " -SkipTests=true -DisableCrossgen=true -PortableBuild=false -CrossBuild=true -- /p:OverridePackageSource=https:%2F%2Ftizen.myget.org/F/dotnet-core/api/v3/index.json /p:OutputRid=tizen.4.0.0-${architecture}"
52         buildCommand = "${dockerCommand} ./build.sh ${buildArgs}"
53     }
54     else if (os == "Linux") {
55
56         // Prep for Portable Linux builds take place on Ubuntu 14.04
57         if (architecture == 'arm' || architecture == 'armel' || architecture == 'arm64') {
58             if (architecture == 'arm64') {
59                 dockerContainer = "ubuntu-16.04-cross-arm64-a3ae44b-20180316023254"
60             }
61             else {
62                 dockerContainer = "ubuntu-14.04-cross-e435274-20180323032140"
63             }
64             dockerCommand = "docker run -e ROOTFS_DIR=/crossrootfs/${architecture} --name ${dockerContainer} --rm -v \${WORKSPACE}:${dockerWorkingDirectory} -w=${dockerWorkingDirectory} ${dockerRepository}:${dockerContainer}"
65             buildArgs += " -SkipTests=true -CrossBuild=true"
66
67             if (architecture == 'armel') {
68                 buildArgs += " -DisableCrossgen=true"
69             }
70
71             buildCommand = "${dockerCommand} ./build.sh ${buildArgs}"
72
73             osForGHTrigger = "Linux"
74             os = "Ubuntu"
75         }
76         else {
77             // Jenkins non-Ubuntu CI machines don't have docker
78             buildCommand = "./build.sh ${buildArgs}"
79             
80             // Trigger a portable Linux build that runs on RHEL7.2
81             osForGHTrigger = "Linux"
82             os = "RHEL7.2"
83         }
84     }
85     else {
86         // Jenkins non-Ubuntu CI machines don't have docker
87         buildCommand = "./build.sh ${buildArgs}"
88         os = "OSX10.12"
89     }
90
91     def newJob = job(Utilities.getFullJobName(project, jobName, isPR)) {
92         // Set the label.
93         steps {
94             if (os == 'Windows_NT' || os == 'Windows_2016') {
95                 // Batch
96                 batchFile(buildCommand)
97             }
98             else {
99                 // Shell
100                 shell(buildCommand)
101             }
102         }
103     }
104
105     Utilities.setMachineAffinity(newJob, os, version)
106     Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
107
108     if (!(architecture == 'arm' || architecture == 'armel' || architecture == 'arm64')) {
109         Utilities.addMSTestResults(newJob, '**/*-testResults.trx')
110     }
111
112     Utilities.addGithubPRTriggerForBranch(newJob, branch, "${osForGHTrigger} ${architecture} ${configuration} Build")
113     
114     ArchivalSettings settings = new ArchivalSettings();
115     def archiveString = ["tar.gz", "zip", "deb", "msi", "pkg", "exe", "nupkg"].collect { "Bin/*/packages/*.${it},Bin/*/corehost/*.${it}" }.join(",")
116     settings.addFiles(archiveString)
117     settings.setArchiveOnSuccess()
118     settings.setFailIfNothingArchived()
119
120     Utilities.addArchival(newJob, settings)
121 }
122
123 // **************************
124 // Define ARM64 building.
125 // **************************
126 //['Windows_NT'].each { os ->
127 //    ['Release'].each { configurationGroup ->
128 //        def newJobName = "${configurationGroup.toLowerCase()}_${os.toLowerCase()}_arm64"
129 //        def arm64Users = ['ianhays', 'kyulee1', 'gkhanna79', 'weshaggard', 'stephentoub', 'rahku', 'ramarag']
130 //        def newJob = job(Utilities.getFullJobName(project, newJobName, /* isPR */ false)) {
131 //            steps {
132 //                // build the world, but don't run the tests
133 //                batchFile("build.cmd -ConfigurationGroup ${configurationGroup} -Architecure x64 -TargetArch arm64 -ToolsetDir C:\\ats2 -Framework netcoreapp1.1")
134 //            }
135 //            label("arm64")
136 //
137 //            // Kick off the test run
138 //            publishers {
139 //                archiveArtifacts {
140 //                    pattern("artifacts/win10-arm64/packages/*.zip")
141 //                    pattern("artifacts/win10-arm64/corehost/*.nupkg")
142 //                    onlyIfSuccessful(true)
143 //                    allowEmpty(false)
144 //                }
145 //            }
146 //        }
147 //
148 //        // Set up standard options.
149 //        Utilities.standardJobSetup(newJob, project, /* isPR */ false, "*/${branch}")
150 //
151 //        // Set a daily trigger
152 //        Utilities.addPeriodicTrigger(newJob, '@daily')
153 //
154 //        // Set up a PR trigger that is only triggerable by certain members
155 //        Utilities.addPrivateGithubPRTriggerForBranch(newJob, branch, "Windows_NT ARM64 ${configurationGroup} Build", "(?i).*test\\W+ARM64\\W+${os}\\W+${configurationGroup}", null, arm64Users)
156 //
157 //        // Set up a per-push trigger
158 //        Utilities.addGithubPushTrigger(newJob)
159 //    }
160 //}
161
162 // Make the call to generate the help job
163 Utilities.createHelperJob(this, project, branch,
164     "Welcome to the ${project} Repository",  // This is prepended to the help message
165     "Have a nice day!")  // This is appended to the help message.  You might put known issues here.