In our organization, we maintain one git repository from which we build multiple microservices. We use Java (spring boot) and maven for building the services.
Each microservice resides in its own maven module + there are "common" (infrastructure) modules that appear (included as dependencies) in all our microservices.
Currently, we don't promote versions of maven artifacts: always run with 0.1-SNAPSHOT in maven, and have a CD process, i.e. each commit reaches our servers
Now, I'm looking for effective way to build our stuff.
Currently, we have Jenkins with slaves that are running on demand in the cloud upon each commit. We have one Jenkins job per microservice.
When someone executes a commit we trigger builds for all microservices, even if the committed files are used only by one microservice with the following command:
mvn --projects backend/microsevice-a --also-make
mvn --projects backend/microsevice-b --also-make
....
mvn --projects backend/microsevice-N --also-make
So, we build the microservice with all its dependencies every time, which is not optimal.
I'm looking for the way to use build only the modules that contain the code that has been changed during the last commit (s)
One solution we thought about is using nexus/artifactory and introduce the full-fledged support for versions, so that every time jenkins builds its stuff it will publish the version in, say, artifactory so that later jenkins will be able to take the "ready" versions out of artifactory, but this looks to be a very complicated approach, because I won't be really able to track what dependency in what revision has been deployed with my microservice.
Since I'm not a DevOps/build guy, I'm more towards the following approach:
- Build some plugin (maven/Jenkins) - that can parse the information out of last commit, analyze the dependency tree of all the backend project and figure out which microservices should be re-built, but It looks like custom development, I'm not sure what are other people do, maybe its already available in Jenkins/maven - I don't know...
Please share your thoughts about these approaches/propose alternatives A help is appreciated :)