Checkout multiple git repos into same Jenkins workspace

后端 未结 9 1620
谎友^
谎友^ 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: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.

提交回复
热议问题