5
votes

My developers team want to use a single GIT repo to store several microservices as it is more convenient to only synchronise one repo.

Unfortunately, all Jenkins pipeline litterature i've found always show a Jenkinsfile at the root of a repo holding only one microservice.

If we consider the following git repository structure:

MyProject
         ¦-> Microservice1
         ¦                ¦-> src/main/java/...
         ¦                ¦-> src/main/docker/Dockerfile
         ¦
         ¦-> Microservice2 (etc.)
         ¦-> Microservice3 (etc.)
         ¦
         ...
         ¦-> Jenkinsfile

How can I detect inside the jenkinsfile which Microservices projects were updated in order to execute de pipeline on those projects only?

2

2 Answers

0
votes

So I've finally found that the solution to this is using several jenkinsfile. However, this is not yet supported but is planned for a futur release of Jenkins Blue Ocean:

https://issues.jenkins-ci.org/browse/JENKINS-43749

Blue Ocean roadmap:

https://jenkins.io/projects/blueocean/roadmap/

0
votes

I don't know if you are somehow restricting yourself via the blue ocean UI, but if you set up a pipeline job via the traditional UI, the jenkinsfile to run is a parameter.

Actually the whole scenario is pretty flexible, much more than it may first appear. I maintain a system where there are about 20 interdependent modules. I have several different build trigger scenarios, depending if I want to build a module isolated or rebuild dependent modules, and whether the jobs are triggered from gitlab (which we use) or are manual. I don't want to maintain multiple copies in each repo.

What I've found I can do is to have yet another repo which contains the Jenkins stuff - it is a shared library as well as containing several effective Jenkinsfile and sub-scripts I use via load(). The Jenkins files loads the relevant real repo and does the appropriate build Job.