1import jobs.generation.Utilities;
2
3def project = GithubProject
4def branch = GithubBranchName
5
6def static setRecursiveSubmoduleOption(def job) {
7    job.with {
8        configure {
9            it / 'scm' / 'extensions' << 'hudson.plugins.git.extensions.impl.SubmoduleOption' {
10                recursiveSubmodules(true)
11            }
12        }
13    }
14}
15
16[true, false].each { isPR ->
17    ['Windows_NT', 'Ubuntu'].each { os ->
18
19        def newJob = job(Utilities.getFullJobName(project, os.toLowerCase(), isPR)) {}
20
21        if (os == 'Windows_NT') {
22            newJob.with {
23                steps {
24                    batchFile("cd corebuild && restore.cmd")
25                    batchFile("cd corebuild && build.cmd")
26                }
27            }
28        } else if (os == 'Ubuntu') {
29            newJob.with {
30                steps {
31                    shell("cd corebuild && ./restore.sh")
32                    shell("cd corebuild && ./build.sh")
33                }
34            }
35        }
36
37        Utilities.setMachineAffinity(newJob, os, 'latest-or-auto')
38
39        Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
40        setRecursiveSubmoduleOption(newJob)
41
42        if (isPR) {
43            Utilities.addGithubPRTriggerForBranch(newJob, branch, "${os} Build")
44        } else {
45            Utilities.addGithubPushTrigger(newJob)
46        }
47    }
48}
49