Remove retention policy from a batch of runs for pipeline cleanup

Occasional Visitor

Hello!

 

We've recently made a major infrastructure change to our system and as a result we have a lot of obsolete pipelines to clean up. For some pipelines with only a few runs I was able to manually remove the retention policies on the runs and delete the pipeline. However with some of the higher-use pipelines there are hundreds of runs being retained, far too many to manually go through and remove the retention policy on each one individually. I have tried disabling the retention policy at the org level, but according to the ui the change only affects new runs, it doesn't remove the policy for old. I also tried making sure that any release that might have been retaining runs was deleted, but deleting the retaining lease doesn't actually remove the retention from the run.

 

So is there a way to either override the retention so I can delete the pipelines, or batch remove the retention from all runs in a pipeline? 

 

Thanks!!

1 Reply

As far as I researched, I haven't found a way to remove retention leases from builds all at once trough the UI.

I've quickly built a tool for this purpose in Node.js that goes trough the builds of a pipeline and deletes leases that retain those builds. You can then delete the pipeline as you normally would.

 

https://github.com/asturlan/RetentionLeaseRemover

 

Hopefully, you will find it useful.