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
Jenkins: Multiple SCM - deprecated. GIT Plugin - doesn't work for multiple repos.
Scripting / pipeline as code - is the way to go.
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.
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.