Add 'reason' parameter to lock() step#982
Conversation
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
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
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
|
⏸️ Auto-merge countdown PAUSED: CI checks are not passing. The countdown will resume when all checks are green. |
…ci/lockable-resources-plugin into feature/lock-step-reason
|
⏳ Auto-merge countdown: This PR will be auto-approved in 2 day(s) if no review is submitted. |
|
|
|
✅ Auto-approved: No review received within 3 days. Merging now. |
|
I think this screenshot clearly shows that the column widths really need some tweaking. There is simply way too much wasted space in some columns and unnecessary squeezing in others. https://github.com/jenkinsci/lockable-resources-plugin/blob/1509.va_6b_5b_5cb_0b_40/src/main/resources/org/jenkins/plugins/lockableresources/actions/LockableResourcesRootAction/tableResources/table.jelly#L63-L69 simply doesn't look good in most cases. |




Summary
Allows users to specify a reason when locking a resource, displayed in the lockable resources UI while the resource is locked.
Usage
\\groovy
lock(resource: 'my-resource', reason: 'Running integration tests') {
// ...
}
\\
Features
eason\ parameter on \lock()\ step
esourceLockReason\ available in groovy scripts
Testing
Documentation
Screenshots
The lock reason is displayed in the Status column of the lockable resources overview page when a resource is locked.
Fixes #520
Fixes #426
@Massakera Thank you for the original PR and idea in #520. I've reimplemented this feature to resolve merge conflicts and align with the current codebase. You can close PR #520 now.