Hi there,
pipeline {
agent { label 'linux' }
...
stages {
stage('Test') {
steps {
script {
def parallelTasks = [:]
parallelTasks["linux"] = generateLinux()
parallelTasks["windows"] = generateLinux()
parallel(parallelTasks)
}
def generateLinux() {
return { node('linux'){
try {
// whatever
}
catch(e){ error(e.toString())
} finally {
docker.image('node:12').inside("-v ${WORKSPACE}/${BASE_DIR}:/app"){
sh '...'
}
}
}
}
}
def generateWindows(){ return { node('windows'){
// whatever
}
}
}
While if I do run two different stages one for each method then no issues at all, so apparently the parallel does something tricky with the tasks internally, see the below snippet:
pipeline {
agent { label 'linux' }
...
stages {
stage('Test') {
steps {
script {
def parallelTasks = [:]
parallelTasks["linux"] = generateLinux() }
}
}
stage('TestWindows') {
steps {
script {
def parallelTasks = [:] parallelTasks["windows"] = generateWindows() } }
def generateLinux() {
return { node('linux'){
try {
// whatever
}
catch(e){ error(e.toString())
} finally {
docker.image('node:12').inside("-v ${WORKSPACE}/${BASE_DIR}:/app"){
sh '...'
}
}
}
}
}
def generateWindows(){ return { node('windows'){
// whatever
}
}
} Even though I raised the above ticket, I wanted to share with you this particular use case as it seems really awkward.