Jenkins HOW-TO: build a project from multiple (Git) repositories

Recently I have been working on a project that has two main modules: Backend and Frontend. The Backend is a Spring Boot application and the Frontend is an AngularJS 1.3 application. While preparing the build we are using Grunt for building AngularJS code and Gradle for building the Spring Boot application. Grunt is creating a JAR file containing all resources and copies it to Spring Boot application. Then Gradle takes the JAR and adds it to the resulting WAR. Long story made short.

Both Backend and Frontend are different Git repositories, initially managed by different teams. Both needs to be checked to the same root folder, so the building process will properly run. In order to do the it on Jenkins, Multiple SCMs Plugin Jenkins plugin can be used. The plugin simplifies the configuration of such a build.

The Jenkins task is updating both repositories and then it exectues a shell shell script that does the work of assembling and deploying the application. The configuration of Multiple SCMs is really simple:

  • Install the plugin: Jenkins > Manage Jenkins > Manage Plugins
  • Create new task: Jenkins > New Item
  • Choose Multiple SCMs in Source Code Management section:

  • Add 1 repository (I am using Git). Choose: Add SCM

  • Enter repository details
  • Add additional behavior. Choose: Add and from dropdown menu select Check out to a sub-directory

  • Provide the sub-directory name
  • Repeat steps 4 to 7 for the second (and other repositories)

Now you can configure other sections of the task, save it and enjoy your new build from multiple repositories.


  1. So when you trigger a build, does it do so for both repos, or just one?

  2. This is great stuff!. Thanks. Quick question, Now suppose we have similar setup like you did here (frontend and backend), where backend is made using (hypothetical) 4 github repos and frontend using 2 github repos (all separate repos). Now say I just want to push changes into sprint branch from feature branches, of only one repo, do we get the ability to selectively push changes from 1 just repo of backend? Using the setup you suggested?


Post a Comment

Popular posts from this blog

Different ways of validating @RequestBody in Spring MVC with @Valid annotation