Adding multiple repositories to a Pipeline

When you add a a new Pipeline job, selecting Pipeline script from SCM displays a form which allows you to select the repository from which the jenkinsfile for the pipeline is loaded. However, it also allows you to add multiple repositories, and each repository added requires its own jenkinsfile.

What does Jenkins do with the Jenkinsfiles from each of the repositories added?

It doesn’t seem to be executing all of them, it seems only one is executed, what’s the logic used to select the jenkinsfile which gets executed?

Is there any documentation out there which explains this well (I’ve yet to find any) ?

i don’t think it requires it. What behavior are you seeing?

I would just recommend using the git or checkout step to grab the extra code your want instead of using the source in the config. The syntax generator will help you fill out all the right parameters

Hi

Thanks for the reply.

I’m talking about the Pipeline script from SCM…

In this particular example i have added two repositories

testcommon and
testscheduler

only testcommon has a jenkinsfile. So after changes to common are made… it finds the JenkinsFile and successfully completes. Whereas when you make changes in testscheduler click the build now button you get

Lightweight checkout support not available, falling back to full checkout.
Checking out git git@bitbucket.org:tonicweb/testcommon.git git@bitbucket.org:tonicweb/testscheduler.git into D:\Jenkins\jobs\test\workspace@script\05ea0cb48bd525399b605d31ef612e4ddaa2c860f1385108c4af38e5a44af149 to read Jenkinsfile
The recommended git tool is: NONE
No credentials specified
No credentials specified
 > C:\Program Files\Git\bin\git.exe rev-parse --resolve-git-dir D:\Jenkins\jobs\test\workspace@script\05ea0cb48bd525399b605d31ef612e4ddaa2c860f1385108c4af38e5a44af149\.git # timeout=10
Fetching changes from 2 remote Git repositories
 > C:\Program Files\Git\bin\git.exe config remote.origin.url git@bitbucket.org:tonicweb/testcommon.git # timeout=10
Fetching upstream changes from git@bitbucket.org:tonicweb/testcommon.git
 > C:\Program Files\Git\bin\git.exe --version # timeout=10
 > git --version # 'git version 2.30.0.windows.2'
 > C:\Program Files\Git\bin\git.exe fetch --tags --force --progress -- git@bitbucket.org:tonicweb/testcommon.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > C:\Program Files\Git\bin\git.exe config remote.origin1.url git@bitbucket.org:tonicweb/testscheduler.git # timeout=10
Fetching upstream changes from git@bitbucket.org:tonicweb/testscheduler.git
 > C:\Program Files\Git\bin\git.exe fetch --tags --force --progress -- git@bitbucket.org:tonicweb/testscheduler.git +refs/heads/*:refs/remotes/origin1/* # timeout=10
Seen branch in repository origin/master
Seen branch in repository origin1/master
Seen 2 remote branches
 > C:\Program Files\Git\bin\git.exe show-ref --tags -d # timeout=10
Checking out Revision 2f7e1e6a7f6eeebaf813520f1fa3d9ff9ec79d1d (origin1/master)
 > C:\Program Files\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > C:\Program Files\Git\bin\git.exe checkout -f 2f7e1e6a7f6eeebaf813520f1fa3d9ff9ec79d1d # timeout=10
Commit message: "fx"
 > C:\Program Files\Git\bin\git.exe rev-list --no-walk 0eddd73a6c4cd37030397e5326865fd5a1c7f19f # timeout=10
ERROR: D:\Jenkins\jobs\test\workspace@script\05ea0cb48bd525399b605d31ef612e4ddaa2c860f1385108c4af38e5a44af149\Jenkinsfile not found
Finished: FAILURE

If you check into common again it’ll pull the jenkins file out of common and run successfully.

I’ve actually got about 5 real repositories and when i run a pipeline job on it, with changes pushed to two or more of the repositories, it seems to be randomly selecting only one of the repositories to pull the jenkins file, I might have thought it pulls the jenkins file only out of the first repository, or if it didn’t work that way, that it pull jenkins files out of each of the repositories which have had changes since the previous build and execute each of them. What it actually does baffles me and makes me wonder if i understand the purpose of it.

Are we clear now?
Similarly, what is the meaning of multiple branches?