# Build trigger on push AND pr

**URL:** <https://drone.discourse.group/t/build-trigger-on-push-and-pr/11117>\
**Category:** Drone Support\
**Created:** [November 14, 2018, 4:38pm UTC](https://drone.discourse.group/t/build-trigger-on-push-and-pr/11117 "2018-11-14T16:38:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rizidoro](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/rizidoro/32/6016_2.png) [@rizidoro](https://drone.discourse.group/u/rizidoro)\
**Post date:** [November 14, 2018, 4:38pm UTC](https://drone.discourse.group/t/build-trigger-on-push-and-pr/11117/1 "2018-11-14T16:38:30Z")

</div>

I have a pipeline which should trigger only when a pull\_request are opened or pull\_request are updated.  
Every time I push some change on this PR, drone triggers 2 builds: one which just clone and another one for the configured pull request.

Is there a way to tell drone to only build on the PR?

My .drone.yml config:

> kind: pipeline  
> name: notifications
> 
> steps:
> 
> - name: test  
> image: ruby:2.3  
> commands:
> - apt-get update && apt-get install -y build-essential nodejs libpq-dev --fix-missing --no-install-recommends && apt-get clean
> - gem install bundler && bundle install
> - bundle exec rake db:create
> - bundle exec rake db:migrate
> - bundle exec rspec  
> environment:  
> RAILS\_ENV: test  
> NOTIFICATION\_DBUSER: postgres  
> NOTIFICATION\_DBHOST: postgres\_service  
> NOTIFICATION\_DBPORT: 5432  
> REDIS\_PROVIDER: redis\_service  
> when:  
> event:
> - pull\_request
> 
> services:
> 
> - name: postgres\_service  
> image: postgres:9.4-alpine  
> environment:  
> POSTGRES\_USER: postgres  
> POSTGRES\_DB: noverde\_cep\_test
> - name: redis\_service  
> image: redis

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [November 14, 2018, 4:51pm UTC](https://drone.discourse.group/t/build-trigger-on-push-and-pr/11117/2 "2018-11-14T16:51:34Z")

</div>

Yes see the Triggers section in the Pipeline documentation.  
[https://docs.drone.io/pipeline/docker/syntax/trigger/](https://docs.drone.io/pipeline/docker/syntax/trigger/)

---

<div class="post-metadata">

**Author:** ![TekTimmy](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/tektimmy/32/4646_2.png) [@TekTimmy](https://drone.discourse.group/u/TekTimmy)\
**Post date:** [August 21, 2020, 2:02pm UTC](https://drone.discourse.group/t/build-trigger-on-push-and-pr/11117/3 "2020-08-21T14:02:35Z")

</div>

@bradrydzewski That triggers on either pull request OR push. We would like to build only when pushing on branches that have a pull request. Background is that the drone pipeline is expensive (resource wise) and time consuming so it should not happen on every push.

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [August 21, 2020, 2:36pm UTC](https://drone.discourse.group/t/build-trigger-on-push-and-pr/11117/4 "2020-08-21T14:36:53Z")

</div>

when you push to a branch with an open pull request, it triggers a `pull_request` synchronization event. Therefore you can instruct Drone to only trigger pipelines for pull requests.

```nohighlight
trigger:
  event:
  - pull_request

```

---

<div class="post-metadata">

**Author:** ![TekTimmy](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/tektimmy/32/4646_2.png) [@TekTimmy](https://drone.discourse.group/u/TekTimmy)\
**Post date:** [August 21, 2020, 6:50pm UTC](https://drone.discourse.group/t/build-trigger-on-push-and-pr/11117/5 "2020-08-21T18:50:39Z")

</div>

@bradrydzewski Thanks for your quick response! I tried that today with BitBucket, push on open pull request does NOT trigger another build with Drone 1.7.0! It just revokes the “successful build” tag from the pull request…  
Ideas are very welcome 😉

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [August 21, 2020, 8:05pm UTC](https://drone.discourse.group/t/build-trigger-on-push-and-pr/11117/6 "2020-08-21T20:05:01Z")

</div>

are you running bitbucket server (self-hosted)? If yes, this is an issue with bitbucket server which, until recently, did not send synchronization events. Bitbucket server recently added support for this capability, but now we need to update code in Drone to support it, which has not happened yet.

> **[Harness Community | Harness Developer Hub](https://developer.harness.io/community/)**
>
> Build relationships through knowledge sharing.

---

<div class="post-metadata">

**Author:** ![TekTimmy](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/tektimmy/32/4646_2.png) [@TekTimmy](https://drone.discourse.group/u/TekTimmy)\
**Post date:** [August 21, 2020, 8:31pm UTC](https://drone.discourse.group/t/build-trigger-on-push-and-pr/11117/7 "2020-08-21T20:31:06Z")

</div>

Thanks for the information! Yes we are running an self-hosted BitBucket. Looking forward to that Drone feature!

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [August 23, 2020, 9:22pm UTC](https://drone.discourse.group/t/build-trigger-on-push-and-pr/11117/8 "2020-08-23T21:22:41Z")

</div>

yes, this is planned for a future release and is published on our trello roadmap:

https://trello.com/c/VSpljG54.html
