Comments (7)
I tweaked https://gist.github.com/odavid/76b6874ed2b421b3eeb838aec0e9e040 and have a Jenkins job run every evening (not sandboxed) to remove locks with certain patterns:
def manager = org.jenkins.plugins.lockableresources.LockableResourcesManager.get()
def resources = manager.getResources().findAll {
(!it.locked) && (
it.name.startsWith("docker_rpminstalled") ||
it.name.startsWith("docker-rpmbuild") ||
it.name.startsWith("rpm-deploy")
)
}
resources.each {
println "Removing ${it.name}"
manager.getResources().remove(it)
}
manager.save()
from lockable-resources-plugin.
@Constantin07 I never have, but others have warned me - see the comments on JIRA bug JENKINS-38906. As I noted there, my situation has very little chance of concurrency issues. Sorry I couldn't help more. In the second loop where the remove
is being called, maybe it can be locked?
from lockable-resources-plugin.
You could setup a nightly job as described on a relevant Jira ticket or you could also apply the same resources modification as a pipeline cleanup stage. Just control the resource is already unlocked and noone is queued to use it (even then, concurrency problems might happen, treat this comment as a workaround)
from lockable-resources-plugin.
@AaronDMarasco-VSI Thanks for sharing. I'm getting java.util.ConcurrentModificationException
exception when calling remove
method with the latest Jenkins (2.164). Do you have the same ?
from lockable-resources-plugin.
It looks like it doesn't allow to remove items from resource list while looping through it.
I just created another list to capture what to delete and then remove them in this loop.
Thanks for reply.
from lockable-resources-plugin.
The original issue should be resolved by the ephemeral locks behavior released in https://github.com/jenkinsci/lockable-resources-plugin/releases/tag/lockable-resources-2.6
from lockable-resources-plugin.
Seems @medianick was faster spotting this then I was working through the open issues after the release 👍
Closing as fixed. Please reopen if there is something I didn't consider.
from lockable-resources-plugin.
Related Issues (20)
- Is there any API documentation on what is supported? Can this be used from command line outside of jenkins? HOT 10
- Missing permission Job/Configure for Administrator
- Adapt plugin for Data Table API 2.0.x HOT 6
- Set reserved timestamp when stealing lock
- manually unlock "globally locked" resource early
- ReservedTimeStamp leads to failure in Plugin:Configuration as Code Plugin during booting jenkins HOT 1
- Add feature to prevent creation of Ephemeral resources
- Sometimes the plugin throws an IndexOutOfBoundsException with multiple locks HOT 1
- Extend lockable-resources build page
- Add timemout attribute to eliminate long stuck when resource is long time locked / reserved
- Sort requested resources by user defined groovy script
- Implement executor count for one resource
- Add way to cancel current queued requests in one job (by groovy)
- Lock the whole pipeline base on variable , and excute stage on specific agent HOT 2
- Jenkins events on lock actions
- Reoccurring null in LockableResourcesManager resources HOT 1
- Make matrix-project optional dependency
- Lock resources whose names are provided by build parameters. HOT 1
- Add ability to "offline" a resource through Declarative pipeline code HOT 2
- Add ability to do custom check on a device when locking
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lockable-resources-plugin.