Question about clone strategy for pull request event

Hi, I am a new learner for Drone. Thank you guys for this amazing product! But I have one question about the clone plug-in.

I found that my drone pipeline clone the target and merge the source branch when trigger the pull request event. Is there a way to change this behavior? (ex: Stay on the source branch.)

I believe this behavior is causing issue when I try to integrate Sonarqube with Drone.
The issue is that since the source branch is already merged into target branch, so Sonarqube can not tell the different between source and target, and it always show no new code for my pull request despite It does have new code in commit.

My current workaround is specify the remote target branch for diff.

There is a SonarQube thread discuss about this situation I think match to what I described. Coverage not showed for manual PR analysis in Drone CI - #5 by giovannigiordano_cas - SonarQube - SonarSource Community

You have two options:

  1. disable the default clone step and provide your own logic. See
  2. globally override the default clone logic by providing your own clone plugin (you could fork the official clone plugin and modify to meet your needs). See
1 Like

Hi, Thank you for answering my question. Your advice has helped me solve the issue.

I try to overwrite the clone step by using the ‘pull/{key}/merge’ branch, and now SonarQube works perfectly on the pull request. I find that is how Jenkins does on the pull request.

I wonder if is there any concern for Drone to merge it manually?

we previously used the merge ref in drone, but it was flaky for some of our users [1], and when we contacted github support about our problems they provided this response:

The /merge refs that are being used here are an undocumented feature and you shouldn’t be relying on them. That feature was build to power Pull Requests in the Web UI, it was not built to be used by 3rd party services. Because it’s undocumented – you should not have any expectations about behavior, the behavior might change at any time and those refs might completely go away without warning. My recommendation is that if you need a merge commit between the base and head refs, you create that merge commit yourself in the local clone instead of relying on merge commits from GitHub. If there’s a reason why you need to rely on this undocumented feature and can’t create merges on your end, please let us know – we’d be interested to hear your use-case.

we now manually merge as github suggested, and have done so for the past few years without any major issues or bug reports from our users (we have ~10,000 activate Drone installations, so when there is an issue, we usually hear about it right away).

[1] Github Claims that Merge Refs are "Undocumented Feature"

1 Like