CircleCI Ideas

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.

  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • Mar 21 2018
  • Taking votes
  • Attach files
  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    18 May 08:49am

    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

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    3 May 09:29am

    Any update on this?

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    15 Apr 08:06am

    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.

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    6 Mar 01:52pm

    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.

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    3 Mar 02:57pm

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

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    25 Feb 06:19am

    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.

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    8 Dec, 2019 02:28am

    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?

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    21 Nov, 2019 02:31pm

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

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    13 Nov, 2019 12:17pm

    what's the ETA for this? Really necessary!

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    10 Oct, 2019 01:58am

    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...

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    26 Sep, 2019 09:43pm

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

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    12 Sep, 2019 04:42pm

    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.

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    4 Aug, 2019 05:12pm

    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 

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    24 Jul, 2019 03:27pm

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

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    8 Jul, 2019 11:49am

    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.

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    13 Jun, 2019 12:32pm

    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.

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    7 May, 2019 06:32am

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

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    5 Mar, 2019 11:59am

    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!

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    28 Feb, 2019 04:31am

    Yeah, this is pretty critical for open source projects

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    8 Nov, 2018 09:26pm

    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.