patternMinor
Running parallel builds from jenkins pipeline job triggers and waits for same job on other project
Viewed 0 times
samebuildswaitsjenkinsotherprojectrunningparallelforand
Problem
I have this test pipeline code, it runs 2 build on different nodes on
I expect it to trigger 2 different builds 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 aSolution
Something needs to be different in other_job2 for tests['x'] and tests['y'].
Example(untested),
More info:
https://www.jenkins.io/doc/pipeline/examples/#jobs-in-parallel
Example(untested),
for (f in [ 'x', 'y' ]) { {
{some code}
build job: "other_job2", parameters: [file_params, string(name:'dummy', value: "${f}")], wait: true, propagate: true
// the dummy parameter is for preventing mutation
}More info:
https://www.jenkins.io/doc/pipeline/examples/#jobs-in-parallel
Code Snippets
for (f in [ 'x', 'y' ]) { {
{some code}
build job: "other_job2", parameters: [file_params, string(name:'dummy', value: "${f}")], wait: true, propagate: true
// the dummy parameter is for preventing mutation
}Context
StackExchange DevOps Q#11528, answer score: 2
Revisions (0)
No revisions yet.