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

Triggering Bitbucket Pull Request Builds on the correct branch in Freestyle projects

XMLWordPrintable

      (Sorry if the solution to this problem is already in the documentation. It does not seems super clear in the documentation how this is supposed to work.)

      In the Bitbucket Server Integration (4.0.0) plugin there is a feature to trigger Jenkins builds when Pull Requests are opened.

      Naturally, we would like to build the source branch of the pull request (to run unit tests for example). However, for Freestyle projects is unclear how to configure pull request triggers to build the source branch.

      In Freestyle projects, Bitbucket pull request triggers can be set up as follows:

      1. In the Source Code Management section, we select Bitbucket Server, and fill in the details:

      (note: if we add no Branch Specifier, there will a default one pointing to the main branch => this will always result in building the default branch; we can set an "any" for the Branch Specifier => but, that results in building random/all branches)

      2. In the Build Triggers section, we select "Bitbucket webhook trigger" with the trigger type "Pull request event":

      This works, but new Pull Requests trigger builds the default/main branch, which is not useful.

      Can somebody help me how to configure these Bitbucket pull request triggers to build the source branch of the pull request?

            Unassigned Unassigned
            atokes Attila
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: