我在这里阅读了有关为多个项目共享标准管道的信息
我有一个用例,我想通过循环中的多个数据运行管道模板。这个管道应该按顺序运行。这是代码:
//Jenkinsfile
startPipeline()
def startPipeline(){
for(i = 0 ; i < 3; i++)
myPipeline(name : "Hello${i}")
}
我有一个管道模板如下:
//vars/myPipeline.groovy
def call(Map pipelineParams){
pipeline {
agent any
stages {
stage('print Hello') {
steps { echo "${pipelineParams.name}" }
}
}
}
}
预期是按顺序运行管道。当我尝试这个时,我得到下面的异常部分异常日志
java.lang.IllegalStateException: Only one pipeline { ... } block can be executed in a single run.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)