简体   繁体   English

Jenkinsfile:如何在多分支管道中检出多个分支源?

[英]Jenkinsfile: how to checkout multiple branch sources in multibranch pipeline?

I've configured multiple branch sources (different repositories) in multibranch pipeline:我在多分支管道中配置了多个分支源(不同的存储库): 多个分支源

And in jenkinsfile I want to checkout all this repositories, I've tried next script:在 jenkinsfile 中,我想查看所有这些存储库,我尝试了下一个脚本:

node {
  stage("Checkout") {
    checkout scm
  }
}

But this script checkouts only first repository.但是这个脚本只检出第一个存储库。 How I can checkout all repositories in one step?如何一步签出所有存储库?

I know I can list all repositories by listing in jenkinsfile itself, but I want to use already provided branch sources.我知道我可以通过在 jenkinsfile 本身中列出来列出所有存储库,但我想使用已经提供的分支源。

This way you can checkout multiple repos in single jenkins build.通过这种方式,您可以在单个 jenkins 构建中签出多个存储库。

stage ('checkout'){
       cleanWs()
       dir ('app-code'){
       git branch: '${branch}', credentialsId: 'jenkins-gitlab', url: 'git@gitlab.xxx.net:xxx/xxx.git'
       }
       dir ('docker'){
           git branch: 'master', credentialsId: 'jenkins-gitlab', url: 'git@gitlab.xxx.net:xxx/docker-xxx.git'
       }
       dir ('charts'){
           git branch: 'master', credentialsId: 'jenkins-gitlab', url: 'git@gitlab.xxx.net:devops/xxx.git'
       }
   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Jenkinsfile禁用Multibranch管道中的分支 - How to disable branch in Multibranch pipeline with Jenkinsfile Jenkins多分支管道具有多个具有相同分支名称的来源 - Jenkins Multibranch Pipeline with multiple sources with the same branch name 如何在 JenkinsFile 多分支管道中使用正则表达式? - How to use regular expression in a JenkinsFile multibranch pipeline? 多分支管道 cron 上的 Jenkinsfile - Jenkinsfile on multibranch pipeline cron 詹金斯文件 | 多分支管道 - Jenkinsfile | Multibranch Pipeline Jenkinsfile:禁用基于 Git 分支名称多分支管道的 UI 参数 - Jenkinsfile: Disable UI parameter based on Git Branch name multibranch pipeline jenkins multibranch jenkinsfile SVN结账 - jenkins multibranch jenkinsfile SVN checkout Jenkins Multibranch Pipeline:如何只结账一次? - Jenkins Multibranch Pipeline: How to checkout only once? 使用jenkinsfile中的branch-env.BRANCH_NAME修改env.BRANCH_NAME变量,以进行多分支管道项目 - Modify env.BRANCH_NAME variable with branch-env.BRANCH_NAME in jenkinsfile for a multibranch pipeline project 有没有办法让 Jenkins 管道在多分支设置中自动检出最新版本的分支? - Is there a way for a Jenkins Pipeline, in a Multibranch setup, to automatically checkout the branch that is at the latest revision?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM