Checkout multiple git repos into same Jenkins workspace

后端 未结 9 1603
谎友^
谎友^ 2020-11-28 04:42

Using Jenkins 1.501 and Jenkins Git plugin 1.1.26

I have 3 different git repos each with multiple projects.

Now I need to checkout all projects from the 3 gi

相关标签:
9条回答
  • 2020-11-28 05:03

    Jenkins: Multiple SCM - deprecated. GIT Plugin - doesn't work for multiple repos.

    Scripting / pipeline as code - is the way to go.

    0 讨论(0)
  • 2020-11-28 05:06

    Since Multiple SCMs Plugin is deprecated.

    With Jenkins Pipeline its possible to checkout multiple git repos and after building it using gradle

    node {   
    def gradleHome
    
    stage('Prepare/Checkout') { // for display purposes
        git branch: 'develop', url: 'https://github.com/WtfJoke/Any.git'
    
        dir('a-child-repo') {
           git branch: 'develop', url: 'https://github.com/WtfJoke/AnyChild.git'
        }
    
        env.JAVA_HOME="${tool 'JDK8'}"
        env.PATH="${env.JAVA_HOME}/bin:${env.PATH}" // set java home in jdk environment
        gradleHome = tool '3.4.1' 
    }
    
    stage('Build') {
      // Run the gradle build
      if (isUnix()) {
         sh "'${gradleHome}/bin/gradle' clean build"
      } else {
         bat(/"${gradleHome}\bin\gradle" clean build/)
      }
    }
    }
    

    You might want to consider using git submodules instead of a custom pipeline like this.

    0 讨论(0)
  • 2020-11-28 05:08

    Checking out more than one repo at a time in a single workspace is possible with Jenkins + Git Plugin (maybe only in more recent versions?).

    In section "Source-Code-Management", do not select "Git", but "Multiple SCMs" and add several git repositories.

    Be sure that in all but one you add as an "Additional behavior" the action "Check out to a sub-directory" and specify an individual subdirectory.

    0 讨论(0)
提交回复
热议问题