Skip to content

Instantly share code, notes, and snippets.

@cccaternberg
Last active April 4, 2018 11:14
Show Gist options
  • Save cccaternberg/da5a3461a3eeaa039ff620f344316e09 to your computer and use it in GitHub Desktop.
Save cccaternberg/da5a3461a3eeaa039ff620f344316e09 to your computer and use it in GitHub Desktop.
node (){
stage ("prepare"){
["1", "2", "3"].each {
println "Item: $it"
// Write a text file there.
dir ("output"){
writeFile file: "${it}-test.txt", text: "$it",encoding: "UTF-8"
}
}
stash name: "myTestFiles", includes: "output/*.*"
}
stage('run-parallel') {
unstash "myTestFiles"
def files = findFiles glob: '**/*-test.txt'
files.each {file -> println file}
def parallelBranches = files.collectEntries { n ->
[(n): {
node('docker-cloud') {
sh "sleep 10"
echo "Done"
}
}]
}
parallel parallelBranches
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment