Git can not find remote ref of Bitbucket Server pull request

Hi,
We have faced an issue with Bitbucket Server pull requests on our pipeline.

  • Bitbucket Server v7.4.0
  • Drone v1.9.0.

However push actions are fine.

We have started to facing this issue after the repository got renamed.

For example I have tried to restart a previous PR (without this issue) when the repo had its original name yet, but then I got the same issue described here.

We have tried to re-sync the repos (close / re-open the PR) again but It doesn’t help so much.

couldn’t find remote ref refs/pull-requests/28/from

this error would indicate that when git tries to clone the pull request, the Bitbucket server is responding that the pull request reference does not exist. If Bitbucket server is returning an error when git is trying to clone a reference, you may need to check your Bitbucket server logs or contact Atlassian support for more details.

Strange we don’t see related issues on logs but after restart the build and close/re-open few times the same PR, It works.
Curious, because the PR ref url https://ci.my-company.com/link/SER/app-server/tree/refs/pull-requests/28/from now redirects to corresponding PR ref but it was not found in the past.

Just to remark that this thread is already reported to Atlassian community.
https://jira.atlassian.com/browse/BSERV-12284?error=login_required&error_description=Login+required&state=465f87b8-e6d0-420d-bc1b-e7b1641beab8

Here is also more related threads

I’ll reiterate here that Bitbucket Server’s pull request refs are not API , and have never been considered API, so the way they work is dangerous to rely on

Their response is rather unfortunate. They effectively blame their customers for using a feature they claim was undocumented, despite the fact that it has been formally documented as the recommended approach for cloning a pull request at https://www.atlassian.com/git/articles/pull-request-proficiency-fetching-abilities-unlocked

Update: I just commented on the issue.

It looks like there is a workaround. We would need to make an API call to generate the diff which in turn would ensure the pull-request references are created.

rest/api/1.0/projects/KEY/repos/slug/pull-requests/N/changes?limit=1

1 Like

Shame Atlassian’s answer even with a previous user’s comment on top since April.
Looks like they are not willing to tackle on this issue.

Our team has realized about the problem just after an major upgrade (v6 to v7) and just this week due failed PRs on Drone pipelines.

Could be this workaround a TODO for Drone team?

Yes, we will unfortunately have to develop a workaround in Drone. We could otherwise be waiting for years for Atlassian support to resolve this matter …

Awesome! I hope is not a burden for Drone team. If you help with testing this we are able do it.

And yeah… our team unfortunately does not trust on Atlassian in this regard.

@joseluisq also looks like there may be a plugin available at https://github.com/Cyanoth/Bitbucket-EagerPR-Updates that solves this issue. Have you tried this as a workaround?

Hey @bradrydzewski thanks for the hint!
We have tested the Java plug-in internally and works as intended. I have also reproduced the same behavior explained above, but without issues this time.
Drone is now able to get those PR references back again.
It was a matter of just upload the .jar file only.

Finally our latest testing output of Drone on same project but using the Eager PR Plugin.

Awesome! However, as a workaround is more than fine for but I don’t know if also Drone can consider to include this workaround as well. Because a PR event on Drone pipelines is a common feature that I think should work out of the box.

Yes, we still plan on implementing the fix / workaround and have an issue in our tracker [1] that can be subscribed to. The java plugin should be used as a temporary fix for now.

[1] https://github.com/drone/go-scm/issues/68

1 Like