Created
March 5, 2019 15:33
-
-
Save ChristophBender/630b3c5aba72e709419122f5a4e68aa2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creation of the stage_list | |
def node_list = [ "Linux" : ["is_docker" : true], "Windows" : ["is_docker" : false]] | |
// Creation of a map of stages | |
def stepsForParallel = node_list.collectEntries { | |
["Build ${it.key}" : transformIntoStage(it.key, it.value)] | |
} | |
// Actual build step (with CMake in this case) | |
def cmake_build(String source_dir, String cmake_generator, String build_type = 'Release') { | |
cmakeBuild buildDir: 'build', buildType: build_type, cleanBuild: true, generator: cmake_generator, installation: 'InSearchPath', sourceDir: source_dir, steps: [[withCmake: true, args: '--config ' + build_type]] | |
} | |
// Creation of the stage | |
def transformIntoStage(nodeLabel, config) { | |
return { | |
// Agend selection based on the label that is passed to node() | |
node("${nodeLabel}") { | |
if(config["is_docker"]) { | |
// For Linux builds it uses a Dockerfile that is located in <root>/jenkins/Dockerfile | |
def myEnv = docker.build('mydockerimg:tag', 'jenkins') | |
myEnv.inside { | |
cmake_build(pwd(), 'Unix Makefiles') | |
} | |
} else { | |
cmake_build(pwd(), 'Visual Studio 14 2015 Win64') | |
} | |
} | |
} | |
} | |
// Run the pipeline | |
pipeline { | |
agent any | |
stages { | |
stage ("Parallel Build") { | |
steps { | |
script { | |
parallel stepsForParallel | |
} | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment