试一试以下内容 - 不能保证以下内容是准确的,但应该能让您朝着正确的方向前进。
您要做的第一件事是在每个存储库中使用一致的 Jenkinsfile,现在您可以通过多种不同的方式做到这一点,但实现此目的的一种方法是使用外部 groovy 管道,以便逻辑可以在整个存储库中保持一致。这方面的一个例子位于here.。跨每个存储库复制 Jenkinsfile 也可以,但是单一的事实来源通常是更好的方法。
node{
deleteDir()
git env.flowScm
def flow = load 'pipeline.groovy'
stash includes: '**', name: 'flowFiles'
stage 'Checkout'
checkout scm // short hand for checking out the "from scm repository"
flow.runFlow()
}
pipeline.groovy 文件包含实际管道的位置如下所示:
def runFlow() {
// your pipeline code
}
// Has to exit with 'return this;' in order to be used as library
return this;
一旦您使用相同的管道逻辑获得了每个触发器,您就可以利用dir 命令克隆和使用不是触发构建的存储库。这方面的一个例子位于here.
node('ATLAS && Linux') {
dir('CalibrationResults') {
git url: 'https://github.com/AtlasBID/CalibrationResults.git'
}
dir('Combination') {
git url: 'https://github.com/AtlasBID/Combination.git'
}
dir('CombinationBuilder') {
git url: 'https://github.com/AtlasBID/CombinationBuilder.git'
}
sh('ls')
sh('. CombinationBuilder/build.sh')
}
将这两个步骤放在一起应该可以实现您在本例中所追求的目标。