Skip to content

Feature: option to automatically abort previous running builds for the same branch/workflow when a new commit is pushed #6655

@kshitijdhara

Description

@kshitijdhara

🔖 Feature description

Add an option to automatically abort previous running builds for the same branch/workflow when a new commit is pushed, except when builds are in the "pushing cache" phase. This would prevent resource waste by stopping outdated builds that will not be deployed, while preserving builds that are already in the final deployment stages.

The feature should include:

  • Configurable toggle per application/workflow
  • Protection for builds in critical phases (e.g., pushing cache, final deployment steps)
  • Clear logging of which builds were aborted and why
  • Option to specify which build phases should be protected from abortion

🎤 Pitch / Usecases

When developers push multiple commits in quick succession to the same branch, Devtron triggers simultaneous builds for each commit. Since only the latest commit will ultimately be deployed and remain active, running multiple builds simultaneously wastes:

  • Compute resources and build agents
  • Time waiting for unnecessary builds to complete
  • CI/CD pipeline capacity that could be used for other projects

Use Cases:

  • Rapid Development Cycles: During active development, developers frequently push small fixes or improvements. Each push triggers a build, but only the final build matters for deployment.
  • Feature Branch Development: When working on feature branches, developers often push incremental commits. Running builds for every intermediate commit is inefficient when only the latest state needs to be built and deployed.
  • Resource Optimization: In environments with limited build agents or compute resources, aborting outdated builds frees up capacity for more recent and relevant builds.

Example Scenario:

  • Developer pushes commit A → Build A starts
  • Developer pushes commit B → Build B starts (Build A should be aborted if not in critical phase)
  • Developer pushes commit C → Build C starts (Build A and B should be aborted if not in critical phases)
  • Only Build C completes and gets deployed

Benefits:

  • 70% reduction in build time (similar to what other platforms achieve with this feature)
  • Reduced resource consumption and costs
  • Faster feedback loops for developers
  • Better utilization of CI/CD pipeline capacity
  • Improved developer experience with faster builds

🔄️ Alternative

Current Workarounds:

  • Manually cancel builds through the Devtron UI (time-consuming and error-prone)
  • Use external scripts to monitor and cancel builds via API calls
  • Accept the resource waste and longer build times

Other CI/CD Platform Solutions:

  • Jenkins offers disableConcurrentBuilds(abortPrevious: true) option
  • TeamCity has built-in build queue optimization
  • GitHub Actions allows canceling in-progress workflows for the same branch

Why Devtron Should Have This:

  • Native integration with Devtron's workflow engine
  • Better understanding of Devtron-specific build phases
  • Seamless integration with existing RBAC and audit logging
  • Consistent user experience within the Devtron platform

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Metadata

Metadata

Labels

enhancementNew feature or requestneeds-triageIssue is not approved or ready-to-work on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions