Show PR Build Status in Bitbucket

We have our collection for building with Team City (version 2017.1.5), and we use the Bitbucket server on the server <version> 4.8> for our git repository. Our GitHub Flow Branching Model

We use the mendhak Team City plugin to report build status to the Bitbucket server. In addition, we created an assembly in the city of the team to build a pull request with a branch trigger: +:refs/(pull-requests/*)/merge .

However, the build status for this branch filter is not visible in the download / bitpage request page.

If we use the filter for branching into function branches (for example, +:refs/heads/(feature/*) ), the build status is displayed correctly on PR. But we are interested in displaying the PR build status in our Pull requests.

We found that since 2013 there has already been an open problem with Atlassian ( yes - almost 5 years ), It seems that this will not be fixed in the near future.

Question:

Are there any workarounds or Bitbucket plugins (or Team City plugins) that can solve this problem. We want to avoid adding an additional filter / trigger to the branch.

I believe that this is a fairly common problem, and it should have been solved by many other teams / people. I just can't find the right resource / material.

Any pointers are highly appreciated.

+5
source share
1 answer

The problem is that the ref you are using (under refs/pull-request/* ) is only internal and does not appear in the Bitbucket web interface.

Imagine you have a repo on a Bitbucket server, for example:

enter image description here

Now suppose you are creating a PR from a branch to master. The link displayed in the Bitbucket user interface does not change, but git clone --mirror shows hidden refs/pull-request/* refs that are created behind the scenes:

 git clone --mirror http://vm.bit-booster.com/bitbucket/scm/bb/rebase-example-1.git cd ./rebase-example-1.git git log --all --date-order --decorate --graph 

Result:

enter image description here

Having Team City, Jenkins or Bamboo, or any other using refs/pull-requests/1/merge (e.g. 01ebefda503c in this example) has one major advantage over building a branch . You must proactively build the real thing (merger) before actually merging. It is like peering into the future.

But it has one main drawback, if you then try to publish the assembly status using the same ref. The Commit id 01ebefda503c not displayed in the Bitbucket user interface, so pull-request build state integration will not receive a successful (or unsuccessful) build.

But there is a great workaround. Let Team City (or Jenkins or Bamboo, etc.) aimlessly push the build status to a preventive merge, and then use curl to hide a copy of the same build status HEAD ^ 2, aka 01ebefda503c^2 aka e466842138b65 .

Same:

 curl --user user:password -H "Content-Type: application/json" -X POST -d \ '{"state":"SUCCESSFUL", "key":"K", "name":"K-9", "url":"http://bit-booster.com/"}' \ http://vm.bit-booster.com/bitbucket/rest/build-status/1.0/commits/e466842138b658a1b09caa0b1caea065194311ce 

Then the build status will be visible on PR.

And unload my Bitbucket add-on . :-)

+5
source

Source: https://habr.com/ru/post/1275093/


All Articles