38

I want to build a project using two Git repositories. One of them contains of the source code, while the other has the build and deployment scripts.

My problem is that I need to have a repository for building and deployment of different parts of the project (big project, multiple repositories, same build and deployment scripts), but Jenkins does not seem to be able to handle this (or I don't know/didn't find how).

Mihai
  • 2,125
  • 2
  • 14
  • 16
  • This is very similar to http://stackoverflow.com/questions/14843696/checkout-multiple-git-repos-into-same-jenkins-workspace – Ola Eldøy Nov 15 '16 at 06:40

5 Answers5

31

UPDATE

Multiple SCMs Plugin is now deprecated so users should migrate to Pipeline plugin.

Old answer

Yes, Jenkins can handle this. Just use Multiple SCMs under Source Code Management, add your repositories and then go to the Advanced section of each repository. Here you need to set Local subdirectory for repo (optional) and Unique SCM name (optional).

Your repository will be pulled to the Local subdirectory which you have set so then you can build them in any order you want.

Updating per harishs answer - you need to install Multiple SCMs Plugin in order to achieve this functionality.

Petr Mensik
  • 26,874
  • 17
  • 90
  • 115
18

Answer from Petr Mensik is right but this does not seem to be available by default in Jenkins. One needs to install Multiple SCM plugin to get this feature: https://wiki.jenkins-ci.org/display/JENKINS/Multiple+SCMs+Plugin

harish
  • 1,836
  • 3
  • 21
  • 26
12

I had the same question, when I looked at the Multiple SCM plugin answer I noticed this plugin is now listed as deprecated. There is a notice that recommends to use a pipeline for this.

Below is a sample config of how I managed to do this with a pipeline.

node() {
  stage ('Extract') {
    parallel 'Extract':{
      dir('project1') {
        git url: 'ssh://git@githost/project1.git'
      }
      dir('project2') {
        git url: 'ssh://git@githost/project2.git'
      }
    }   
  }
}
carl verbiest
  • 1,113
  • 1
  • 15
  • 30
2

Just sharing my experience when dealing with Multiple SCM. If you want to add multiple git repositories in your jenkins build, make sure that the other git plugin versions are compatible with Multiple SCM plugin. Here's a list of plugin with version which worked for me:

  • GitHub API Plugin 1.44
  • Jenkins GIT client plugin 1.6.2
  • Jenkins GIT plugin 2.0.1
  • Git Server Plugin 1.2
  • Multiple SCMs 0.2

Earlier I upgraded to Multiple SCM 0.3 and I was not able to add any git repo in that section.

Rgds, Manu

John McGehee
  • 9,117
  • 9
  • 42
  • 50
Manu Garg
  • 21
  • 1
0

When you add another SCM via the Multiple SCM plugin and choose Git. You can specify to 'Check out to a sub-directory' via the 'Additional Behaviours' options for a repo. Thus you can have multiple repos in a workspace.

enkor
  • 7,527
  • 3
  • 31
  • 55
  • I realise this is an answer for an old question, but I came across the question with the same issue and found a solution. – enkor Feb 28 '18 at 20:56