PR builds could not be promoted

I have a pipeline with following triggers:

trigger:
 event:
  - pull_request
  - promote

When I’m pushing to PR branch it builds just fine. But when I’m trying to promote same build it fails:

Initialized empty Git repository in /drone/src/.git/

  • branch master -> FETCH_HEAD
  • [new branch] master -> origin/master
  • git checkout 4556f5179c1c99abad782ed0ea30d0cc0d7ec017 -b master
    fatal: reference is not a tree: 4556f5179c1c99abad782ed0ea30d0cc0d7ec017

So it’s trying to checkout PR target branch (master in my case) and commit is not there because PR haven’t merged yet.

Expected behaviour: build is performed for PR source branch

Please post your full .drone.yml and provide the version of Drone you are using.

Drone - latest version from Docker hub.

kind: pipeline
type: docker
name: default

steps:
- name: show-env
  image: bitnami/git
  commands:
  - env

trigger:
 event:
  - pull_request
  - promote

I just tested and was able to promote a pull request without issue:

I think it depends on what you promoting - build triggered by push (shown in list as “username pushed branch” - this one works) or pull request (“username opened pull request” - this one fails when promoted)

In the example screenshot above, I promoted this build which was triggered by pull request. If you look closely at the logs in the screenshot you will see git fetch origin refs/pull/7/head

Previous versions of Drone did have problems cloning pull requests that were promoted, but that was fixed by this patch which was merged back in Aug 2019