Pom*_*m12 13 jenkins jenkins-pipeline jenkinsfile
从另一个管道脚本加载管道脚本时,两个管道不会在同一节点上执行:第一个在我的主节点上执行,第二个在从节点上执行.
我正在使用Jenkins管道,Pipeline Script from SCM
以这种方式为很多工作提供选项:
我的每个作业都使用Poll SCM
选项定义了相应的Git repo 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'
}()
Run Code Online (Sandbox Code Playgroud)
我的common-pipeline.groovy管道可以实现诸如构建,发布或部署工件之类的实际内容,例如:
{ ->
node() {
def functions = load 'common/functions.groovy'
functions.build()
functions.release()
functions.deploy()
}
}
Run Code Online (Sandbox Code Playgroud)
现在我不想强制每个作业的节点,所以两个管道都有,node("master")
或者node("remote")
因为我真的不想手动处理它,但是我希望一旦第一个管道在特定节点上运行(主机,slave1,slave2,slave3)第二个/加载的管道在同一个节点上执行,因为否则我的实际Git存储库代码不能从其他节点的工作区获得......
有没有什么方法可以指定我希望我的第二个管道在第一个管道的同一节点上执行,或者在使用该load
步骤时可能传递一个参数?
您可以为第二个管道制作一个参数化作业,并在触发第二个作业时使用参数来控制节点。
第二条管道看起来像这样:
node(runhereParam) {
}
Run Code Online (Sandbox Code Playgroud)