我正在研究基本的Jenkins管道,并从他们的文档中提取了此示例,但是出现错误,提示“未找到名为管道的项目”
// in this array we'll place the jobs that we wish to run
def branches = [:]
//running the job 4 times concurrently
//the dummy parameter is for preventing mutation of the parameter before the execution of the closure.
//we have to assign it outside the closure or it will run the job multiple times with the same parameter "4"
//and jenkins will unite them into a single run of the job
for (int i = 0; i < 4; i++) {
def index = i //if we tried to use i below, it would equal 4 in each job execution.
branches["branch${i}"] = {
//Parameters:
//param1 : an example string parameter for the triggered job.
//dummy: a parameter used to prevent triggering the job with the same parameters value.
// this parameter has to accept a different value each time the job is triggered.
build job: 'freestyle', parameters: [
string(name: 'param1', value:'test_param'),
string(name:'dummy', value: "${index}")]
}
}
parallel branches
由未知或匿名用户启动 以耐久性级别运行:MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] parallel
[Pipeline] { (Branch: branch0)
[Pipeline] { (Branch: branch1)
[Pipeline] { (Branch: branch2)
[Pipeline] { (Branch: branch3)
[Pipeline] build
[Pipeline] }
Failed in branch branch0
[Pipeline] build
[Pipeline] }
Failed in branch branch1
[Pipeline] build
[Pipeline] }
Failed in branch branch2
[Pipeline] build
[Pipeline] }
Failed in branch branch3
[Pipeline] // parallel
[Pipeline] End of Pipeline
ERROR: No item named Pipeline found
Finished: FAILURE
答案 0 :(得分:0)
您应该创建一个自由式作业,并将该作业名称放入管道作业中-这样管道作业将调用您创建的新作业。
在提供参数的同时,自由式作业也应具有这些参数