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?