Jenkins - Mono repository build only changed the folder My Organization keeps a single git repository in bitbucket. It hosts multiple projects under the same branch.
I have to automate the build process using Jenkins; I configured a webhooks that invoke on any push to  development branch. Now, I have to generate a build based on which sub-directory the changes happened in, e.g. if code was committed  to /Microservice2, it will generate build for MS2, _etc.

How does one achieve this using Jenkins?
Am assuming you are familiar with Groovy at basic level. Well, you could do the following with Shell scripts too, but I have done something similar using native capabilities of Groovy.


Store changeset by running git log ..., those three dots mean you should go thru' git-log man page to check the options that will list the changed files with folder names.
Iterate thru' the changeset (from item 1) to identify the folder (microservice 2 or 3, 4, so on and so forth).
Once the service is identified, try and set few environment variables that can be reused in other scripts, if you want. Advantage with this approach is, you stand to have access to them until the completion of build.


Hope this helps.