My Organization is keeping only one git repository in bitbucket, that hosts multiple projects under same branch, Now I have to automate build process using Jenkin. I configured a webhooks that invoke on any push happening to development branch. Now I have to generate a build based changed sub directory. Ex if any one committed code to Microservice2 to it will generate build for MS2. Please let me know how we are achieve this using Jenkin.

enter image description here

Thanks Niks

| improve this question | | | | |

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.

  1. 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.
  2. Iterate thru' the changeset (from item 1) to identify the folder (microservice 2 or 3, 4, so on and so forth).
  3. 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.

| improve this answer | | | | |
  • could you please share the sample jenkinsfile? – gamechanger17 Feb 18 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.