#!/usr/bin/groovy // -*- mode: groovy -*- // Jenkins pipeline // See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/ import groovy.transform.Field /* Unrestricted tasks: tasks that do NOT generate artifacts */ // Command to run command inside a docker container def dockerRun = 'tests/ci_build/ci_build.sh' // Utility functions @Field def utils def buildMatrix = [ [ "enabled": true, "os" : "linux", "withGpu": true, "withNccl": true, "withOmp": true, "pythonVersion": "2.7", "cudaVersion": "9.1" ], [ "enabled": true, "os" : "linux", "withGpu": true, "withNccl": true, "withOmp": true, "pythonVersion": "2.7", "cudaVersion": "8.0" ], [ "enabled": true, "os" : "linux", "withGpu": true, "withNccl": false, "withOmp": true, "pythonVersion": "2.7", "cudaVersion": "8.0" ], ] pipeline { // Each stage specify its own agent agent none // Setup common job properties options { ansiColor('xterm') timestamps() timeout(time: 120, unit: 'MINUTES') buildDiscarder(logRotator(numToKeepStr: '10')) } // Build stages stages { stage('Jenkins: Get sources') { agent { label 'unrestricted' } steps { script { utils = load('tests/ci_build/jenkins_tools.Groovy') utils.checkoutSrcs() } stash name: 'srcs', excludes: '.git/' milestone label: 'Sources ready', ordinal: 1 } } stage('Jenkins: Build & Test') { steps { script { parallel (buildMatrix.findAll{it['enabled']}.collectEntries{ c -> def buildName = utils.getBuildName(c) utils.buildFactory(buildName, c, false, this.&buildPlatformCmake) }) } } } } } /** * Build platform and test it via cmake. */ def buildPlatformCmake(buildName, conf, nodeReq, dockerTarget) { def opts = utils.cmakeOptions(conf) // Destination dir for artifacts def distDir = "dist/${buildName}" def dockerArgs = "" if(conf["withGpu"]){ dockerArgs = "--build-arg CUDA_VERSION=" + conf["cudaVersion"] } // Build node - this is returned result node(nodeReq) { unstash name: 'srcs' echo """ |===== XGBoost CMake build ===== | dockerTarget: ${dockerTarget} | cmakeOpts : ${opts} |========================= """.stripMargin('|') // Invoke command inside docker sh """ ${dockerRun} ${dockerTarget} ${dockerArgs} tests/ci_build/build_via_cmake.sh ${opts} ${dockerRun} ${dockerTarget} ${dockerArgs} tests/ci_build/test_${dockerTarget}.sh """ } }