aboutsummaryrefslogtreecommitdiff
path: root/jenkins/package_builder.groovy
blob: 2391abf068974fa1aab7b741133b88b04d29f727 (plain) (blame)
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
node(this.label) {

    dir(this.parent_workspace) {

        println("inherited workspace: ${this.parent_workspace}")
        println("Nodelabel: ${this.label}")
        println("${env.JOB_NAME}")
        println("${env.JOB_BASE_NAME}")
        println("${env.BUILD_NUMBER}")
        println("${env.NODE_NAME}")
        println("${env.WORKSPACE}")
        println("${env.JENKINS_HOME}")
        println(currentBuild.buildVariables)
        println("parameter py_version: ${this.py_version}")

        env.PATH = "${this.parent_workspace}/miniconda/bin/:" + "${env.PATH}"

        // Make the log files a bit more deterministic
        env.PYTHONUNBUFFERED = "true"

        this.OSname = null
        uname = sh(script: "uname", returnStdout: true).trim()
        if (uname == "Darwin") {
            this.OSname = "MacOSX"
            env.PATH = "${env.PATH}:/sw/bin"
            this.CONDA_BLD_OUTPUT_DIR = "osx-64"
        }
        if (uname == "Linux") {
            this.OSname = uname
            this.CONDA_BLD_OUTPUT_DIR = "linux-64"
        }
        assert uname != null
        println("${this.CONDA_BLD_OUTPUT_DIR}")

        // In directory common to all package build jobs, run conda build for this
        // package.
        dir("conda-recipes") {

            build_cmd = "conda build"

            stage("Build") {
                build_args = "--no-test --no-anaconda-upload --python=${this.py_version}" +
                    " --numpy=${this.numpy_version} --skip-existing"
                stat = 999

                stat = sh(script: "${build_cmd} ${build_args} ${env.JOB_BASE_NAME}",
                            returnStatus: true)
                println("Shell call returned status: ${stat}")
                if (stat != 0) {
                    currentBuild.result = "FAILURE"
                }
            }

            stage("Test") {
                build_args = "--test --no-anaconda-upload --python=${this.py_version}" +
                    " --numpy=${this.numpy_version} --skip-existing"
                stat = sh(script: "${build_cmd} ${build_args} ${env.JOB_BASE_NAME}",
                            returnStatus: true)
                println("Shell call returned status: ${stat}")
                if (stat != 0) {
                    currentBuild.result = "UNSTABLE"
                }
            }

        } // end dir
    }

} //end node