title: Jenkins multibranch pipeline with multiple repo to build for the changed repo only
body: <p>So, I have really a complex repository structior (atleast what I think), and I need to achieve CI-CD there. All my webhooks and setting are complete and now I am stuck with the deployment parts.</p>
  
  <p>So I have 4 different repos which ultimately builds a tar file for the whole production.</p>
  
  <pre><code>Repo1: https://gitlab.example.com/repo1
  Repo2: https://gitlab.example.com/repo2
  Repo3: https://gitlab.example.com/repo3
  Repo4: https://gitlab.example.com/repo4
  </code></pre>
  
  <p>I have JenkinsFile at the root of every repo (its kind of same Jenkinsfile under every project).</p>
  
  <p>Here is snip of my git checkout pipeline script:</p>
  
  <pre><code>    properties ([
      [$class: 'GitLabConnectionProperty', gitLabConnection: 'gitlab'],
      pipelineTriggers([[
          $class: "GitLabPushTrigger",
          triggerOnPush: true,
          triggerOnMergeRequest: true,
          // triggerOpenMergeRequestOnPush:"both",
          triggerOnNoteRequest: true,
          noteRegex: "CI BUILD THIS AGAIN",
          // skipWorkInProgressMergeRequest: true,
          // ciSkip:false ,
          //setBuildDescription: true,
          addNoteOnMergeRequest:true,
          addCiMessage: true,
          addVoteOnMergeRequest: true,
          acceptMergeRequestOnSuccess: true,
          //branchFilterType: "NameBasedFilter",
          //targetBranchRegex: "feature-decc-changes",
          //includeBranchesSpec: "feature-decc-changes,master,stage,prod",
          excludeBranchesSpec: "dev"
      ]])
  ])
  
  stage('CHECKOUT: Checkout the Repos '){
          steps {
              checkout([$class: 'GitSCM', branches: [[name: "**"]],
              doGenerateSubmoduleConfigurations: false,
              extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '$BUILD_NUMBER/node']],
                          submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${GIT_SSH_KEY_ID}",
                          url: 'git@gitlab.example.com:repo1.git']]])
  
              checkout([$class: 'GitSCM', branches: [[name: "**"]],
              doGenerateSubmoduleConfigurations: false,
              extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '$BUILD_NUMBER/angular']],
                          submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${GIT_SSH_KEY_ID}",
                          url: 'git@gitlab.example.com:repo2.git']]])
  
              checkout([$class: 'GitSCM', branches: [[name: "**"]],
              doGenerateSubmoduleConfigurations: false,
              extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '$BUILD_NUMBER/common']],
                          submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${GIT_SSH_KEY_ID}",
                          url: 'git@gitlab.example.com:repo3.git']]])
  
              checkout([$class: 'GitSCM', branches: [[name: "**"]],
              doGenerateSubmoduleConfigurations: false,
              extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '$BUILD_NUMBER/extra']],
                          submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${GIT_SSH_KEY_ID}",
                          url: 'git@gitlab.example.com:repo4.git']]])
          }
  </code></pre>
  
  <p>}</p>
  
  <p>Here for any change in in any of the branch, it is creating the build and randomly checking out any of the branch from the repo and creating the build.</p>
  
  <p>But I want jenkins to checkout the branch which has changed just now. For exa. if I pushed a change to "feature-abc" branch, under repo2, it should checkout that branch "feature-abc" from repo2 and all other repo. Also if feature-abc branch doesn't exists, checkout from a custom repo (eg. default master).</p>
  
  <p>Please let me know if I am not clear. I will try to provide more information.</p>