Hey guys. What is the best Jenkins setup for this scenario.
Assume I have a mono-repository which contains 3 directories for 3 different but related projects. Each project has its own way of deployment. There are 2 branches main and staging. If project 1 has changes on branch staging, the specific deployment approach for branch staging of project 1 must run. In the similar way for other two projects.
Using Jenkins I am using the multiple-branch Pipeline. Is this the best configuration?
In my opinion the best configuration would be having 3 different repos.
However, if this cannot be done Jenkins exposes a set of methods to identify which files have been changed from the previous execution of a pipeline.
Be aware that if a pipeline is restarted manually the set of changed files could be empty.
So if the flow you are implementing include this use case you could use a git command to get the list of changed files from the current commit and the previous one… Or from the current merge commit and the previous merge commit if your flow is PR based. It gets a little bit tricky to identify pushes with multiple commits…
I really appreciate your opinion. What of having one jenkinsfile and use something like this to handle both having 3 different projects in one repo and having 2 branches?
Yes, this can work. Be aware that the changeset can be empty if you rerun the pipeline manually. If that needs to be handled I believe you can iterate currentBuild.changeSets and get the latest not empty changeset in case the current one is.