aboutsummaryrefslogtreecommitdiff
path: root/jenkins/package_builder.groovy
blob: 92fbae4cdfb4c94f6914b91a9ae01fc46e70cf25 (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
69
70
71
72
73
74
75
node(this.label) {

    dir(this.parent_workspace) {

        env.PATH = "${this.parent_workspace}/miniconda/bin/:" + "${env.PATH}"
        env.PYTHONPATH = ""
        // Make the log files a bit more deterministic
        env.PYTHONUNBUFFERED = "true"
        def time = new Date()

        println("\n" +
        "    Package Build Info Summary:\n" +
        "${time}\n" +
        "JOB_DEF_GENERATION_TIME: ${JOB_DEF_GENERATION_TIME}\n" +
        "inherited workspace: ${this.parent_workspace}\n" +
        "this.Nodelabel: ${this.label}\n" +
        "env.JOB_BASE_NAME: ${env.JOB_BASE_NAME}\n" +
        "env.JOB_NAME: ${env.JOB_NAME}\n" +
        "env.BUILD_NUMBER: ${env.BUILD_NUMBER}\n" +
        "env.NODE_NAME: ${env.NODE_NAME}\n" +
        "env.WORKSPACE: ${env.WORKSPACE}\n" +
        "env.JENKINS_HOME: ${env.JENKINS_HOME}\n" +
        "parameter py_version: ${this.py_version}\n" +
        "PATH: ${env.PATH}\n" +
        "PYTHONPATH: ${env.PYTHONPATH}\n" +
        "PYTHONUNBUFFERED: ${env.PYTHONUNBUFFERED}\n")

        // In the directory common to all package build jobs,
        // run conda build --dirty for this package to use any existing work
        // directory or source trees already obtained.
        dir("conda-recipes") {

            cmd = "conda build"

            stage("Build") {
                build_cmd = cmd
                args = ["--no-test",
                        "--no-anaconda-upload",
                        "--python=${this.py_version}",
                        "--numpy=${this.numpy_version}",
                        "--skip-existing",
                        "--override-channels",
                        "--channel defaults",
                        "--dirty"]
                for (arg in args) {
                    build_cmd = "${build_cmd} ${arg}"
                }
                stat = 999
                stat = sh(script: "${build_cmd} ${env.JOB_BASE_NAME}",
                          returnStatus: true)
                if (stat != 0) {
                    currentBuild.result = "FAILURE"
                }
            }

            stage("Test") {
                build_cmd = cmd
                args = ["--test",
                        "--python=${this.py_version}",
                        "--numpy=${this.numpy_version}"]
                for (arg in args) {
                    build_cmd = "${build_cmd} ${arg}"
                }
                stat = 999
                stat = sh(script: "${build_cmd} ${env.JOB_BASE_NAME}",
                          returnStatus: true)
                if (stat != 0) {
                    currentBuild.result = "UNSTABLE"
                }
            }

        } // end dir
    }

} //end node