What if you could get all your project's code from different places with just one simple step?
Why Multiple SCM repositories in Jenkins? - Purpose & Use Cases
Imagine you have a project that uses code from several places, like different folders or teams, and you try to get all that code manually before building your software.
Doing this by hand means copying files from many places, which takes a lot of time and can cause mistakes like missing updates or mixing wrong versions.
Using Multiple SCM repositories in Jenkins lets you automatically pull all needed code from different sources in one go, making your build process smooth and error-free.
git clone repo1
cd repo1
# copy files manually from repo2
cd ..
git clone repo2pipeline {
agent any
stages {
stage('Checkout') {
steps {
dir('repo1') {
checkout([$class: 'GitSCM', userRemoteConfigs: [[url: 'repo1']], branches: [[name: '*/main']]])
}
dir('repo2') {
checkout([$class: 'GitSCM', userRemoteConfigs: [[url: 'repo2']], branches: [[name: '*/main']]])
}
}
}
}
}You can build projects that depend on many code sources easily and reliably, saving time and avoiding errors.
A company builds a web app that uses a backend API from one team and a frontend UI from another; Jenkins pulls both repos automatically to build and test the full app.
Manual code gathering is slow and risky.
Multiple SCM repositories automate pulling code from many sources.
This leads to faster, safer, and more reliable builds.