Status: Resolved (View Workflow)
I'm using lock() in the stage options of a declarative pipeline and really like the feature to automatically create the resource if it does not yet exist. That should save some maintenance. However as time goes on and resources change, this means the number of resources builds up until someone cleans them out.
We should have a choice for manually created locks to be temporary - i don't necessarily care whether the resource exists when no one is using it, just that only one job use it at a time.
May be related to: JENKINS-34892
The overall scenario is related to Jenkins agents - I want a stage to deploy a server, followed by stages to execute client tests, but I need the server locked the whole time so that no other job tries to use it. Currently I'm stuck with double maintenance, keeping the same server list in both the agent and the lockable resources. If lock() both lets me create resources on the fly and declare them temporary so they are deleted when no one is using them, then I don't need duplicate maintenance - I only need to maintain the agents, not the lock data.