jenkinsci / jenkinsci/lockable-resources-plugin
Using QueueTaskDispatcher to block jobs using a locked resource before deploying to node
- Dominant language
- Java
- Stars
- 99
- Forks
- 205
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 8
Description
Hi,
I don't know if I'm writing this in the correct place, but I have been wondering about how to solve the following problem:
Given:
A declarative Jenkinsfile 'A' that references label 'B':
`Pipeline { agent { label: 'B'} ... }`
One of the stages in the Pipeline takes Lock 'L'.
When:
- There exists N jobs using Jenkinsfile 'A'
- K nodes with labels 'B'
Then:
If any job of the set N takes the lock 'L', I want the rest N-1 to be blocked with CauseOfBlockage set to BecauseLabelIsBusy.
So only 1 node should be running and the rest K-1 should be free for other jobs of another set to execute on.
_Note_: This is needed to lock resources to different hardware setups, in reality the lock string is a parameter passed by the job. Some jobs don't need any resource and thus will pass BUILD_TAG as a unique lock string.
This way we should be able to have higher utilization of the nodes and avoid having dedicated nodes for specially constrained jobs.
I have been looking around and I found two plugins that if combined in someway might give a good solution:
- Lockable plugin (to manage the locking mechanism)
- Build-blocker-plugin (to hook to QueueTaskDispatcher extension point)
Am I looking in the right direction? or can this be totally done by the Lockable plugin?
Thank you in advance for your feedback!
Contributor guide
Assessment
This issue has not been assessed yet.