1

I have a complex Maven project structure that has many defined dependencies in it. Also dependencies used in the project are not just external but also internal and I am working on them. All of them are repositories stored on Gitlab. There is defined dependency graph that looks like a tree.

Example

Here is a simple example of how dependencies are defined:

          /--> C
A ---> B -        /--> D
          \--> D -
                  \--> E

In this example it can be seen that Maven project A has dependency on project B. Also project B has included dependencies C and D inside it. Project D includes dependencies on projects D and E.

We can now split this tree in layers numbered from 0 to 3:

  3 |   2   |    1   |   0  
____________________________
    |       | /--> C |
  A |---> B |-       | /--> D
    |       | \--> D |-
    |       |        | \--> E

After every commit/merge into develop branch for all projects, pipeline for build and deployment will automatically run.

The tree is much more complex, but for example this is enough good.

PROBLEM

If I commit some changes into project E, I have to merge my feature branch into develop branch so the automatic build and deployment of JAR file will be done, but now the boring part starts... I have to do the same for every Maven project starting from E to the left side in above graph and the only change there is the new version of the E project in their POM files. I also have to deploy new SNAPSHOT versions for all projects from right layers to left, but also in every layer I have to deploy projects from top to bottom. For example, I will have to first deploy project C and then D inside layer number 1.

Deployment order would look like this:

E, C, D, B, and then finally A.

What I want to achieve?

After I commit my changes into project E, I would like that in the order defined above all the projects starting from E to the left side:

  • Use new version of the project E in their POM files
  • Change their version to one higher
  • Run the build and deploy script

What I do now?

Currently I am using a single runner (to be sure that I will deploy only one repository at the time) for all projects above and I am doing this manually. I am manually replacing new version of the project in all POM files in all projects and doing it in the order described above. I am also waiting for pipeline to finish and when I see that it is done, I am doing then manually same thing for next project, until I don't finish the project A.

Is there any way to automate this? I need some solution for automatic SNAPSHOT version update for example, then some autimated way of deploying all the projects from right to left (maybe to use multi-project pipelines?).

Chuck Nuris
  • 71
  • 1
  • 6
  • Nice question! We had the same problems and solved them with using a combination of multi-project-pipelines, child-pipelines and maven-versions-plugin. I will soon answer your question with our approach. – Jakob Liskow Sep 15 '22 at 13:08
  • Thank you @JakobLiskow, I already thought about Gitlab Multi-project pipelines. I just thought that there is some other better tool for automating all these that people are using in IT sectors. I am excited about your comment :) – Chuck Nuris Sep 16 '22 at 15:18
  • @JakobLiskow, can you please give me some useful links that I could use to help me find a solution before you don't answer my question? That would help me a lot. – Chuck Nuris Sep 20 '22 at 12:28
  • Sorry for not answering yet. I'm busy at the moment. Useful links: https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html#dynamic-child-pipelines https://stackoverflow.com/a/72865207/3535187 https://stackoverflow.com/a/68269921/3535187 https://jsonnet.org/ https://stackoverflow.com/a/51514850/3535187 – Jakob Liskow Sep 20 '22 at 15:46

0 Answers0