I have this test pipeline code, it runs 2 build on different nodes on build_servers
as expected.
pipeline {
agent { label 'myserver' }
stages {
stage('1') {
steps {
script {
def tests = [:]
for (f in [ 'x', 'y' ]) {
tests["${f}"] = {
node('build_servers') {
stage('Clean Workspace') {
echo "cleaning up Ws ${f}"
step([$class: 'WsCleanup'])
}
stage('create Wspace txt file') {
script {
props="Wspace=${workspace}"
dir ( 'wspace') {
writeFile file: 'params.txt', text: props
}
}
}
stage('Run other job') {
script {
println('calling other project')
props = readProperties file: "wspace/params.txt"
file_params = props.collect {
string(name: it.key, value: it.value)
}
build job: "other_job2", parameters: file_params, wait: true, propagate: true
}
}
}
}
}
parallel tests
}
}
}
}
}
I expect it to trigger 2 different builds on other_job2
, but it submits just one job and both tests['x'] and tests['y']
waits for the same job to finish, why is that? should it not create 2 different jobs in other_job2
project, one for x
and one for y
?
in the console output, I see build #5 for both [x] and [y] exactly as shown below:
[x] Starting building: TEST » other_job2 #5
[y] Starting building: TEST » other_job2 #5
Also, I am printing ${f}
in echo "cleaning up WS...
line, I expected to see both x and y, but I see only cleaning up Ws y
printed for both [x]
and [y]
as below
[x] cleaning up Ws y
[Pipeline] cleanWs
[x] [WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] done
[Pipeline] echo
[y] cleaning up Ws y
[Pipeline] cleanWs
[y] [WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] done