Trigger new build when a Pull Request is opened

Circle CI should generate a new build when a pull request is opened on github. The current implementation uses the branch's most recent commit result, instead of generating a brand new build.

Consider the following situation.

1) An engineer creates a branch within github, and pushes code up at their leisure. Circle CI builds the project on each commit.
2) When it comes time to make a pull request, the engineer opens up a PR on github, without creating a new git commit.
 
This workflow does not seem to trigger a new build of the branch on Circle CI, and instead Circle CI uses the build result of the most recent commit as the build status of the Pull Request. This seems to be an obvious workflow flaw given that I may have additional logic to build a PR artifact for testing purposes, vs the normal branch commit process. This has been discussed both here and here on your forums as well.

I have found 2 additional configurations under "advanced settings" that compliment this idea, but do not do what I intend.
• Build forked pull requests
• Only build pull requests

As a counterpoint, you can configure both Jenkins and Travis CI to do this, so this seems like a pretty straightforward use case of the platform. Obviously, if you if you push an additional commit to the branch that already has an existing PR, the additional variables or logic within Circle CI will be present.

  • Guest
  • Mar 21 2018
  • Taking votes
  • Attach files
  • Desmond Ho commented
    18 May 08:49

    even the f__king google cloud build can do this
    how come circle ci not having such essential features for 1.5 yrs after reported

  • mike dodd commented
    03 May 09:29

    Any update on this?

  • Guest commented
    15 Apr 08:06

    This is a very basic feature that is mysteriously missing only from CircleCI. We will soon have to migrate to TravisCI because of this. Unfortunate.

  • Guest commented
    06 Mar 13:52

    This is a workaround, however there is a way using the new pipelines API in CircleCI to trigger a build when you open a PR.

    Currently when we close a PR in our workflow we listen for a github event for PR closures that then posts that to a lambda webhook which then calls the CircleCI API in order to trigger a workflow to destroy an ephemeral environment we build per PR.

    So this is possible, which means I'm sure you can do the exact same thing when opening a PR by using a github event that calls a lambda that calls CircleCI's pipelines API to trigger a workflow to run on the branch you have just opened the PR on.

    Obviously ideally this sort of basic thing should be configurable from CircleCI, however using the new API, a github event and a lambda this is possible for anyone who just needs to get this working in the meantime.

  • Guest commented
    03 Mar 14:57

    We have been waiting so much time for this... Now that github actions supports on_pullrequest we are looking to migrate to actions

  • Jamie Armstrong commented
    25 Feb 06:19

    We are part way through migrating to circleci from another ci service and have ran into this same limitation, any update on when this will be available? We are currently at a decision point in our migration where without this functionality we may need to abandon circlci.

  • Daniel Whitston commented
    December 08, 2019 02:28

    I don't see any way to do CI properly without triggering build on pull requests and passing test results back to GitHub. I feel like I must be missing something here. What's the plan? Merge and pray?

  • Davide Pedranz commented
    November 21, 2019 14:31

    Any news on this? It would be really useful to have this feature!

  • Peter Bocan commented
    November 13, 2019 12:17

    what's the ETA for this? Really necessary!

  • L Sherman Parris commented
    October 10, 2019 01:58

    I will add that I am part of a medium sized company that just made the decision to NOT use CircleCI due to this very issue, combined with the alarming amount of CircleCI reps in the forums giving generic responses to these huge issues ("we're working on it" - 2 years later: ...). Come on guys this is literally the most fundamental Continuous Integration function there is, how can you be this far along and not have proper handling of PRs.

    I switched to a competitor (not going to name) and this is super simple to accomplish, like ridiculously so in comparison...

  • Luke Thompson commented
    September 26, 2019 21:43

    Any timeframe on when this capability will be added? It’s such an important feature. 

  • Stephen D commented
    September 12, 2019 16:42

    Conversely, it would be quite nice to trigger a job when a PR is closed/merged.

     

    This is shamelessly cribbing from GitlabCI's dynamic environments and review apps: https://docs.gitlab.com/ee/ci/review_apps/index.html#configuring-review-apps

     

    I would love it if CircleCI ran a job I defined (which would `terraform destroy`) when the branch was deleted / PR was closed.

  • Benjamin Assadsolimani commented
    August 04, 2019 17:12

    Hey guys, I found a solution to this problem and posted it here: https://discuss.circleci.com/t/how-to-trigger-pr-pipelines-in-circleci-for-bitbucket/31715 

     

    Cheers,

    derbenoo 

  • Guest commented
    July 24, 2019 15:27

    Unfortunately we had to go back to Travis CI because of this issue. This workflow is critical to us

  • Michael Smith commented
    July 08, 2019 11:49

    Yeah, currently to get SonarCloud checks to show up on a PR we have to remember to re-run the build after we open the PR. Either this idea or CCI-I-315 would address that.

  • Guest commented
    June 13, 2019 12:32

    There are so many requests for this and no response from CircleCI as to where it is in priority. If you are researching CI systems to use, I would avoid CircleCI for this reason, and for the lack of support for this feature.

  • Luke Thompson commented
    May 07, 2019 06:32

    Hi, Can someone @CircleCI comment on this? This is a critical feature for us.

  • Stephen Colebourne commented
    March 05, 2019 11:59

    I'm amazed that this isn't the number one feature request (It should have been implemented before launch). Right now, CircleCI simply doesn't test pull requests properly.

    This old thread provides some more details. The requirement is to listen to the webhooks for pull request opened/updated and trigger a build of the merge_commit_sha as specified in the docs. Each time a commit is pushed to the root branch or the PR the build has to be redone. This is then fed back as a second status to GitHub. See also the Travis docs for details of what needs implementing.

    Travis, Shippable and no doubt many other CI systems support this. And it really is basic CI functionality. Please prioritise this!

  • Cam C commented
    February 28, 2019 04:31

    Yeah, this is pretty critical for open source projects

  • Rob McDaniel commented
    November 08, 2018 21:26

    Heroku CI also does this. I'm pretty surprised circleCI does not. It's a pretty basic scenario for CI tools isnt it? I'd like to build on commits AND on PR's, not either/or.