summaryrefslogtreecommitdiff
path: root/Jenkinsfile
blob: 0717b286c88bea6b0d095c0ede7121d3b1b03ae9 (plain)
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
#!/usr/bin/env groovy

def ci_checkers_targets = [
    ["commit-checker", "openttd/compile-farm-ci:commit-checker"],
]
def ci_builds_targets = [
    ["linux-amd64-clang-3.8", "openttd/compile-farm-ci:linux-amd64-clang-3.8"],
    ["linux-amd64-gcc-6", "openttd/compile-farm-ci:linux-amd64-gcc-6"],
    ["linux-i386-gcc-6", "openttd/compile-farm-ci:linux-i386-gcc-6"],
]

def ci_checkers_stages = ci_checkers_targets.collectEntries {
    ["${it[0]}" : generateCI(it[0], it[1])]
}
def ci_builds_stages = ci_builds_targets.collectEntries {
    ["${it[0]}" : generateCI(it[0], it[1])]
}

def generateCI(display_name, image_name) {
    return {
        githubNotify context: 'openttd/' + display_name, description: 'This commit is being built', status: 'PENDING'

        try {
            dir("${display_name}") {
                unstash "source"

                docker.image("${image_name}").withRun("--volumes-from ${hostname} --workdir " + pwd()) { c->
                    sh "docker logs --follow ${c.id}"
                    sh "exit `docker wait ${c.id}`"
                }
            }

            githubNotify context: 'openttd/' + display_name, description: 'The commit looks good', status: 'SUCCESS'
        }
        catch (error) {
            githubNotify context: 'openttd/' + display_name, description: 'The commit cannot be built', status: 'FAILURE'
            throw error
        }
    }
}

node {
    ansiColor('xterm') {
        stage("Checkout") {
            checkout scm

            // Ensure we also have origin/master available
            sh "git fetch --no-tags origin master:refs/remotes/origin/master"

            stash name: "source", useDefaultExcludes: false
        }

        stage("Checkers") {
            parallel ci_checkers_stages
        }

        stage("Builds") {
           parallel ci_builds_stages
        }
    }
}