Answers: <p>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.</p>
  
  <ol>
  <li>Store changeset by running <code>git log ...</code>, 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.</li>
  <li>Iterate thru' the changeset (from item 1) to identify the folder (microservice 2 or 3, 4, so on and so forth).</li>
  <li>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.</li>
  </ol>
  
  <p>Hope this helps.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-02-18T11:51:22.050Z
Answers: could you please share the sample jenkinsfile?
Answers: gamechanger17
Answers: CC BY-SA 4.0
Answers: 2018-05-25T07:06:09.653Z
Answers: 2018-05-25T07:06:09.653Z
Answers: Ramu
Body: <p>My Organization keeps a single git repository in bitbucket. It hosts multiple projects under the same branch.</p>
  <p>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, <em>e.g.</em> if code was committed  to <code>/Microservice2</code>, it will generate build for <code>MS2</code>, _etc.</p>
  <p><a href="https://i.sstatic.net/h1TSo.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/h1TSo.png" alt="enter image description here" /></a></p>
  <p>How does one achieve this using Jenkins?</p>
  
Comments: CC BY-SA 4.0
Comments: 2020-06-21T11:32:45.117Z
Comments: Could you please clarify whether you are using Jenkins pipeline as code, or job dsl?
Comments: Bruce Becker
Tags: <jenkins><jenkins-plugins>
Title: Jenkins - Mono repository build only changed the folder
UserDisplayName: user1340004
ThreadText: # Jenkins - Mono repository build only changed the folder
  
  (Asked by: username_0 on 2018-05-25)
  
  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.
  
  [![enter image description here](https://i.sstatic.net/h1TSo.png)](https://i.sstatic.net/h1TSo.png)
  
  How does one achieve this using Jenkins?
  
  **Tags:** jenkins, jenkins-plugins
  
  > **Comments:**
  > **username_1**: Could you please clarify whether you are using Jenkins pipeline as code, or job dsl?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-05-25. Score: 2
  
  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.
  
  > **Comments:**
  > **username_3**: could you please share the sample jenkinsfile?  
  
  ---
  
  