Auto-cancel builds for default branch

Originally asked here: https://discuss.circleci.com/t/auto-cancel-builds-on-default-branch/5536

We would like auto-cancel to apply to the default branch, specifically because we have a deploy action associated with it. The deploy is slow and multiple builds are often racing with each other and we occasionally get an older build that finishes after a newer one, leaving us with older code deployed. (This is only for a staging environment deploy in our case though.)

  • Guest
  • Feb 5 2018
  • Taking votes
  • Attach files
  • Celestine Kao commented
    27 Apr 21:19

    If you use AWS, check out the workflow-manager orb

  • Joep Kemperman commented
    November 19, 2019 15:12

    We would also like this. We don't automatically deploy our default branch, but we do have a couple projects where we often merge several PR's in a short time. Their builds take more than an hour, so this results in either a bunch of wasteful builds, or having to manually cancel these builds.

  • Naotoshi Seo commented
    May 12, 2019 14:19

    Same here. We use the default `master` branch as a development branch. We want to auto-cancel redundant builds.

  • Neil Poulin commented
    November 07, 2018 23:52

    I agree with the original poster. Or, something else that might be nice in the meantime is the ability to auto-cancel jobs are in a Holding status after X of them are in that status. Meaning, We have a bunch of builds that are awaiting prod - since they're not auto-cancelling, i'll end up with a large number of jobs waiting to be promoted to production. My suggestion is to only hang onto the last X number (3, 5, 10) of them, and cancel the rest since it's very unlikely that we'll ever promote such an old build.