从另一个管道脚本加载管道脚本时,两个管道不会在同一个节点上执行:第一个在我的主节点上执行,第二个在从节点上执行。
我正在Pipeline Script from SCM
以这种方式使用带有选项的 Jenkins 管道来完成很多工作:
我的每个作业都使用选项定义了它们对应的 Git
Poll SCM
存储库 URL,以便在对我的代码进行更改时自动轮询存储库(基本作业用法)。我的每个作业都在其存储库的根目录定义了一个简单
Jenkinsfile
的,而里面的管道脚本基本上什么都不做,只是加载一个更通用的管道。
例如:
node {
// --- Load the generic pipeline ---
checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'http://github/owner/pipeline-repo.git']]]
load 'common-pipeline.groovy'
}()
我的common-pipeline.groovy管道执行实际的工作,例如构建、发布或部署工件,例如:
{ ->
node() {
def functions = load 'common/functions.groovy'
functions.build()
functions.release()
functions.deploy()
}
}
现在我不想为每个作业强制节点,所以两个管道都有node("master")
,或者node("remote")
因为我真的不想手动处理它,但是一旦第一个管道在特定节点上运行(或者master,slave1,slave2,slave3)第二个/加载的管道在同一个节点上执行,因为否则我的实际 Git 存储库代码不能从其他节点的工作区获得......
有什么方法可以指定我希望我的第二个管道与第一个管道在同一个节点上执行,或者在使用load
step 时可能传递一个参数?