How to remove all resources with label
I'm using pipeline workflow to create some resources with label and after the build is done I want to delete/remove all resources with this label.
To create it i'm using this lines for example:
LockableResourcesManager.get().createResourceWithLabel("my_resource1", "my_label")
LockableResourcesManager.get().createResourceWithLabel("my_resource2", "my_label")
and now i need to delete all resources with "my_label" using pipeline (groovy) is there a way to do it? (even loop each of "my_resourcesX" and delete it) can you add deleteResourcesWithLabel("my_lable") or lockableResource.delete()
First: I'm not the developer of this project.
I faced the same problem (running many jobs that need to be migrated to pipeline. Jobs are generating a large amount of lockableResources).
A temporary fix: adding _disposable at the end of the resource name at creation. and implementing a free routine that checks if the resource is still needed and ends with "_disposable" Need to implement it again for 2.0. Temporary fix and needs testing.
Working on it.
btw. According to https://issues.jenkins-ci.org/browse/JENKINS-38906 (in the comment section) This behavior doesn't seem to be safe. But without this fix, this plugin is simply not usable for me. The list of lockable resources would grow to 200+ (dynamically created names).
Another way would be: Adding a keyword at the end/front of the resourceName. Displaying "normal" resources in the upper half of the lockableResources page. Displaying keyword resources in the lower half of the lockableResources page.
For dynamically created resources that can be freed soon, does ephemeral resource solve this nowadays?
Also, a PR #204 was posted for ephemeral labels (with generated randomized resource names) that might address another aspect of this puzzle...