Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to build only the latest version on a branch?

Patrick Flood December 11, 2018

We're looking for a way to configure Bamboo/Bitbucket for Pull Request builds such that:

1) Each branch can only queue one build at a time

2) When a build starts, it should use the latest available commit on the source branch (and associate the build with that commit in Bitbucket)

Our current builds take over an hour to run all stages, and the number of builds we can run in parallel is limited by software licenses and agent availability, which can lead to long queue waits.  Our PR branches are triggered per-commit, so if developers push additional changes to their branches while waiting in the queue they build up larger backlogs, leading to more commits, and more queued builds, ad infinitum.  We've been encouraging developers to behave responsibly and kill unnecessary builds when they push new changes, but you can imagine how effective that is.

In essence, what we want is that when a new build is pushed, bitbucket and bamboo look for existing builds on the corresponding plan branch and either update the target commit to the latest, or delete the pending builds from the queue and add a new one.

We're down to write a plugin for this if need be, but I haven't found API calls that let us update the commit associated with a build before it runs - anyone know if something like this is possible?

1 answer

0 votes
Foong
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 14, 2019

Try the option "Enable quiet period" at Bamboo Bitbucket repository setting > Change detection options so that Bamboo will wait for a certain interval before a new build is added to the queue.

For more information, refer to this documentation

Specifies a delay after a single commit is detected before the build is started. This allows multiple commits to be aggregated into a single build.

Patrick Flood January 15, 2019

We considered that, but we find that it's not a good option for our scenario - with builds at a minimum of an hour long (not accounting for queue waits) adding a delay long enough to have a useful impact also adds significant time to builds, and still doesn't stop multiple builds from being queued.

Is there any way to update existing queued builds to point to a new commit before they begin?

Foong
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 15, 2019

How about disabling Concurrent builds at Administration > Plans > Concurrent builds ?

After disabled, a new commit from Bitbucket will not be able to trigger another build when the current build is still running.

After the current build finish running, user will have to create a new commit to trigger another build.

Patrick Flood January 15, 2019

Still not quite what we're looking for, unfortunately.  If new commits are made while the build is running we still need to have the latest built automatically, whereas if a build is already queued we'd like it replaced with the latest commit.

A combination of non-concurrent builds per plan branch and frequent polling (to automatically start a new build if new commits are available when the current build ends) is probably the closest we can get with the built-in capabilities, but it still doesn't really address our requirement that builds update to the latest available commit on the branch when they begin.  I'm still hoping there's a way to achieve that through the API which we haven't found yet.

Foong
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 11, 2019
After the current build finish running, user will have to create a new commit to trigger another build.

Sorry for the mistake. I have just checked that there is no need to create a new commit to trigger another build. Bamboo will trigger a new build automatically after the previous build finish.

If new commits are made while the build is running we still need to have the latest built automatically, whereas if a build is already queued we'd like it replaced with the latest commit.

Feature request https://jira.atlassian.com/browse/BAM-3947

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events