Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-71864

Need a feature to continue build trigger from Jenkins when "Branches to Build" option in Pipeline Jobs is specified to specific branch and pull request is opened using different source branch to "Branches to build" relevant branch.

XMLWordPrintable

      Let's consider an example of two branches master and development (originated from master). As per the current behavior of the plugin, if we assign the "Branches to Build" parameter in the Pipeline job as the master branch, Jenkins build gets triggered if we push anything to the master-specific Branch.
      In such a condition, Jenkins listens to Bitbucket about a change and triggers a very first build for the latest commit in a master branch. After this, we open any new pull request by keeping the source branch as any other branch like development and targeting the same branch mentioned in the "Branches to Build" option (master) in the pull request, no build will get triggered. If we push a new change to the development branch of Pull Request, no build will be triggered as Jenkins still focusing on the master branch.
      This behavior is not observed in the Multibranch Pipeline jobs but the requirement is to use only Pipeline jobs hence need some functionality to continue the builds trigger if any changes arrive at the development branch as well as on Pull Request opening from any source branch to target (master) branch in our example.

      Scenario: (Through which requirement of feature has been observed)

      • Created a simple master and development branch in the repository with one merge between both branches (Development to Master Branch). Merge is successful.
      • Now created Jenkins Pipeline job with the branch as /refs/heads/development/1.0
      • Did a new push to the development branch -> Everything went smoothly and the Jenkins build got triggered.
      • Now changed “Branches to Build” in Jenkins job from  /refs/heads/development/1.0 to /*master and did a new commit on the development branch -> did push -> result is:
        Build got triggered but with master branch commit details instead of development.  (But why - as changes are in Development Branch and not in the master) — Below is the console output entry.
      • Now Opened a pull request from Development to Master Branch -> no new build triggered in Jenkins
      • Now again pushed a new commit to the development branch -> no new build triggered
      • If I do any new push to the master branch (new commits - merge conflict can occur - so need to resolve merge conflict first) - Jenkins build gets triggered.
        Otherwise, need to delete the build history in Jenkins for specific commits which got triggered for the master branch -> then push any new commit to the Development branch -> it works (same as a customer use case)
        What I understood is -> as we are defining “Branches to Build” in the Jenkins job as /*master -> Jenkins monitoring changes to master only. But the question is this scenario:
        Where changing “Branches to Build” in Jenkins job from  /refs/heads/development/1.0 to /*master and did a new commit on the development branch -> did push -> allowing:
      • Build to trigger but with master branch commit details instead of development.
      • After this, it is not allowed to trigger any build on push and pull requests open at the development branch until we delete the latest build from Jenkins build history.
        Like - Checking out Revision d154736752a6c39780582ae7971b77892f798ec2 (refs/remotes/revision_commit_master/master)

      Please provide some feature through which this requirement can be fulfilled.

            Unassigned Unassigned
            nsharma2 Nitin
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: