I’m currently using drone to build a static website and deploy to kubernetes. Drone is also deployed on kubernetes.
Whenever an admin of the website makes a change in the CMS a webhook posts to the drone api which creates a new build. I’m using concurrency: { limit: 1 } to make sure I only deploy one thing at a time. If the admin makes a bunch of changes, a queue of pending builds are created. I actually only care about the latest build so I’m trying to find if there’s a way to automatically cancel a pending build if a new build is created.
To summarise, I’m looking to have the queue look something like
correct, when you create a build using the API it has event type custom. The --auto-cancel-pushes flag enables automatic canceling when the event type is push.
hmm, this is the only immediate solution I can think of …
Drone supports creating system-wide webhooks [1]. You could setup a small microservice that receives webhooks and, on build creation, uses the API to list [2] and cancel [3] pending builds for the same repository.
I would have to consider the implications a bit further, but we may accept a pull request that modifies the logic so that --auto-cancel-push also includes custom events [4][5]. We would need to ensure this change in behavior would not cause any regressions or unexpected behavior for our existing users.