Add an updateLock step to alter resources in pipelines#305
Add an updateLock step to alter resources in pipelines#305gaspardpetit wants to merge 4 commits intojenkinsci:masterfrom
Conversation
|
I just realized the |
|
I take this back, working straight on the |
|
I worked a bit more on this - so the original pipeline looks like this - using the LockableResourcesManager directly: With this propose change, I am simplifying it down to After this change, the step I'd be missing would be a |
jimklimov
left a comment
There was a problem hiding this comment.
I haven't mastered step creation yet, so this PR looks great to me (possibly also as a pattern/checklist to look up to in the future) and has it all - with UI, help and tests included :)
|
Any update on this? this feature will be super useful for our use case... in fact, many PR requests by @gaspardpetit are exactly what I am looking for to fully adopt this plugin. |
| resource.setDescription(""); | ||
| resource.setLabels(""); | ||
| resource.setNote(""); | ||
| resource.setEphemeral(true); |
There was a problem hiding this comment.
the user shall be inform about that
- in the job log
- in the UI like setting some other description. ( in this case I will not change note, labels) Just set ephemeral = true.
One hit more. What happens, when other job is waiting for this resource? This one will be on release deleted. The next one will create it again, or in worst case crashed the job.
|
Hi @gaspardpetit, Thank you for this valuable contribution! The \updateLock\ step is a great feature that many users have been asking for. Unfortunately, after 4+ years this PR has fallen significantly behind master (1013 commits), and there have been major changes to the codebase including:
Given these conflicts, I've decided to do a fresh reimplementation based on your original design. Your implementation served as excellent reference material! The new implementation will be in a separate PR and will:
Feel free to close this PR at your convenience. Your contribution is greatly appreciated, and proper credit will be given in the new PR! Best regards |
This step allows pipelines to dynamically manage lockable resources: - Create new resources (createResource: true) - Delete existing resources (deleteResource: true) - Modify labels (setLabels, addLabels, removeLabels) - Set notes (setNote) Based on the original design from PR #305 by @gaspardpetit. Fixes #305
|
Thanks for letting me know! Apologies for not keeping it up to date - the project I was working on got disbanded, so priorities shifted. The feature was super useful for us to reserve multiple game dev kits and integrate them in our CICD pipeline. Glad it was useful for the new patch! |
This step allows pipelines to dynamically manage lockable resources: - Create new resources (createResource: true) - Delete existing resources (deleteResource: true) - Modify labels (setLabels, addLabels, removeLabels) - Set notes (setNote) Based on the original design from PR #305 by @gaspardpetit. Fixes #305
This step allows pipelines to dynamically manage lockable resources: - Create new resources (createResource: true) - Delete existing resources (deleteResource: true) - Modify labels (setLabels, addLabels, removeLabels) - Set notes (setNote) Based on the original design from PR #305 by @gaspardpetit. Fixes #305
* Add updateLock pipeline step for resource management This step allows pipelines to dynamically manage lockable resources: - Create new resources (createResource: true) - Delete existing resources (deleteResource: true) - Modify labels (setLabels, addLabels, removeLabels) - Set notes (setNote) Based on the original design from PR #305 by @gaspardpetit. Fixes #305 * Remove @SInCE TODO - not applicable for plugins * Add updateLock step documentation to README * fix: Add CSRF protection and permission checks to doCheck* methods Addresses security warnings from github-advanced-security[bot]: - Add @RequirePOST annotation to doCheckResource, doCheckAddLabels, doCheckRemoveLabels, and doCheckDeleteResource - Add @AncestorInPath Item parameter and permission checks to prevent unauthorized form validation calls
* Add updateLock pipeline step for resource management This step allows pipelines to dynamically manage lockable resources: - Create new resources (createResource: true) - Delete existing resources (deleteResource: true) - Modify labels (setLabels, addLabels, removeLabels) - Set notes (setNote) Based on the original design from PR #305 by @gaspardpetit. Fixes #305 * Remove @SInCE TODO - not applicable for plugins * Add updateLock step documentation to README * Add 'reason' parameter to lock() step Allows users to specify a reason when locking a resource, displayed in the lockable resources UI while the resource is locked. Usage: lock(resource: 'my-resource', reason: 'Running integration tests') { // ... } Features: - New 'reason' parameter on lock() step - Reason displayed in UI status column while locked - Reason cleared automatically when resource is unlocked - Works with label-based and resource-based locking - Reason preserved when lock request is queued - Environment variable 'resourceLockReason' available in groovy scripts Fixes #520 * feat: Add reason parameter to reserve button When a user reserves a resource via the Reserve button, they are now prompted to provide a reason. The reason is: - Stored in the lockReason field (shared with lock() step) - Displayed in the resources table - Cleared when the resource is unreserved Changes: - LockableResource: Add reserve(userName, reason) overload - LockableResourcesManager: Add reserve(resources, userName, reason) - doReserve: Read reason parameter from request - table.jelly: Show reason for reserved resources, add i18n template - lockable-resources.js: Prompt for reason on reserve action - table.properties: Add dialog messages * fix: consolidate i18n templates to avoid duplicate IDs * feat: Enhance reservation logging and add authentication check * refactor: improve logging format for resource reservation and user authentication (#1009) * fix: include reason in toString(), steal action, and fix spotless formatting
This PR proposes to add a new
updateLockstep which can be used to alter the resource configuration. MaybeupdateResourcewould be better, but I thought users of this plugin would findupdateLockmore intuitive.With this change, the following can be altered:
New locks are created persistent (non-ephemeral). The use case for this can be having a job that would configure the locks based on an external source (ex. scm). I have not yet figured out how the sync could remove invalid locks (we will probably need a way to list locks so the ones removed from scm can be deleted - open for discussion)
Deleted locks are set to ephemeral if currently locked.
Once #299 is in, I will submit another PR to allow properties to be altered as well.