我有两个管道-CallingPipeline
和CalledPipeline
。 CallingPipeline
个呼叫CalledPipeline
-
CallingPipeline
代码是-
pipeline {
agent any
stages {
stage('Parallel-Run') {
parallel {
stage("VM1"){
steps {
echo "In parent VM1"
build job: 'CalledPipeline', parameters: [string(name: 'VMName', value:"VM1")]
}
}
stage("VM2"){
steps {
echo "In parent VM2"
build job: 'CalledPipeline', parameters: [string(name: 'VMName', value:"VM2")]
}
}
stage("VM3"){
steps {
echo "In parent VM3"
build job: 'CalledPipeline', parameters: [string(name: 'VMName', value:"VM3")]
}
}
}
}
}
}
CalledPipeline
具有构建参数VMName
,以下是其代码-
pipeline {
agent any
stages {
stage('Stage-I') {
steps {
echo "VMName is " + VMName
echo "Executing Stage-I"
}
}
stage('Stage-II') {
steps {
echo "VMName is " + VMName
echo "Executing Stage-II"
}
}
stage('Stage-III') {
steps {
echo "VMName is " + VMName
echo "Executing Stage-III"
}
}
}
}
我运行CallingPipeline
时,可以看到其中的每个阶段都是并行执行的,即调度CalledPipeline
,但最后只触发了CalledPipeline
的一个构建,而不是三。 CallingPipeline
的控制台输出为-
In parent VM1
[Pipeline] build (Building CalledPipeline)
Scheduling project: CalledPipeline
[Pipeline] echo
In parent VM2
[Pipeline] build (Building CalledPipeline)
Scheduling project: CalledPipeline
[Pipeline] echo
In parent VM3
[Pipeline] build (Building CalledPipeline)
Scheduling project: CalledPipeline
Starting building: CalledPipeline #5
Starting building: CalledPipeline #5
Starting building: CalledPipeline #5
[Pipeline] }
[Pipeline] }
您能否建议一种有效的方法,以便在CalledPipeline
阶段不使用睡眠的情况下为CallingPipeline
触发三个构建?