5

I'm using Blue Ocean against Bitbucket Server. I want a new build to occur:

  • When a Pull Request is created or updated
  • When master is updated (basically, when a PR is merged to master)

It appears that I can do the first by choosing "Discover Branches: Only branches that are also filed as PR's". I can do the second by choosing "Filter by name: master".

But if I specify both, it seems to apply the name filter to discovered branches, so no PR's are ever discovered. Furthermore, it never builds master because master is never the subject of a PR (we have master locked against direct commits, as is common in enterprise development.)

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Craig Riecke
  • 121
  • 1
  • 6

1 Answers1

5

I figured it out but it was not intuitive. You must add two BitBucket Branch Sources, both pointing to the same Repository. The first must be the Filter by Name: Master. The second must be "Discover Branches: Only branches that are also filed as PR's". If they're in the opposite order, they won't work.

Craig Riecke
  • 121
  • 1
  • 6
  • Is this still working? I can't get it to work as you describe. I have the PR source working fine. I've tried adding sources for _Filter by Name (with wildcards)_ and for _File by Name (with regular expression)_, both before and after the PR source. I've tried adding the Filter sources in the same source as the PR source. Nothing is working :( – Paul Hicks Apr 03 '19 at 03:37
  • Got it working. My first source has two behaviours. The first is _Discover Branches_ with strategy _Exclude branches that are also filed as PRs_. The second behaviour of the first source is _Filter by name (with wildcards): *master*_. The second source is _Discover pull requests from origin_ with strategy _Merging the pull request with the current target branch revision". This is giving me the expected one branch _master_ and all pull requests (as visualized in Blue Ocean and Classic). – Paul Hicks Apr 03 '19 at 04:11