Looking for suggestions on how to implement a LIFO queue

Firstly, thanks for a really good product. I’m enjoying my discovery of Circle CI and find that it provides a lot of the things I need out of the box without further configuration on my part. The Orb feature is super useful and very comprehensive.

Now for my question, I’d like to implement a LIFO queue of builds waiting to be processed by jobs with an ability to auto-cancel older builds. I’ve already described in detail how I implemented this in Jenkins and now I’d like to know if there’s an official way to achieve the same in Circle CI. Looking forward to responses from the team!

Hi @relaxdiego,

I believe the Auto-cancel redundant builds feature could be what you’re looking for :thinking:

Keep in mind that this feature will only work on non-default branches.

Hi @relaxdiego,

I haven’t taken the time to read your epic post in detail just yet but
I’ve implemented something that sounds very similar to what you’re
looking for on top of CCI using the API and a DynamoDB locking
mechanism. It’s the best I could come up with since CCI doesn’t provide
any kind of concurrency controls on top of their pipelines.

Essentially, you use the pipelines API to grab all the running pipelines
and, if there are more than one, you either proceed with the build (and
grab the DynamoDB lock for the suspenders part of the belt and suspenders
set up), cancel yourself, or queue.

I haven’t taken the time to write up a post about it formally though.
Does that sound like it would be what you were looking for? This might
be the motivation I need to write up the post. :slight_smile:

@timvisher You’ve piqued my interest fir sure :slight_smile:

Maybe I can get around to writing that post then. :slight_smile: