Skip to content

Add 'reason' parameter to lock() step#982

Merged
github-actions[bot] merged 24 commits intomasterfrom
feature/lock-step-reason
Apr 19, 2026
Merged

Add 'reason' parameter to lock() step#982
github-actions[bot] merged 24 commits intomasterfrom
feature/lock-step-reason

Conversation

@mPokornyETM
Copy link
Copy Markdown
Contributor

@mPokornyETM mPokornyETM commented Mar 31, 2026

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

  • New
    eason\ 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
    esourceLockReason\ available in groovy scripts

Testing

  • Added \LockStepReasonTest\ with 7 test cases covering the new functionality
  • All tests pass locally

Documentation

  • Updated README with usage example
  • Added help files for the new parameter

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.

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
@mPokornyETM mPokornyETM requested a review from a team as a code owner March 31, 2026 15:28
@mPokornyETM mPokornyETM marked this pull request as draft April 1, 2026 20:22
mPokornyETM and others added 4 commits April 2, 2026 13:54
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
@mPokornyETM mPokornyETM marked this pull request as ready for review April 3, 2026 11:46
@mPokornyETM
Copy link
Copy Markdown
Contributor Author

Manual verification OK:
image

image

@mPokornyETM mPokornyETM added the merge-in-3-days-without-review Auto-approve countdown label Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 4, 2026

⏸️ Auto-merge countdown PAUSED: CI checks are not passing. The countdown will resume when all checks are green.

@mPokornyETM mPokornyETM closed this Apr 7, 2026
@mPokornyETM mPokornyETM reopened this Apr 7, 2026
@github-actions github-actions Bot added merge-in-2-days-without-review Auto-approve countdown and removed merge-in-3-days-without-review Auto-approve countdown labels Apr 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Auto-merge countdown: This PR will be auto-approved in 2 day(s) if no review is submitted.

@github-actions github-actions Bot added merge-in-1-day-without-review Auto-approve countdown and removed merge-in-2-days-without-review Auto-approve countdown labels Apr 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Auto-merge countdown: This PR will be auto-approved in 1 day(s) if no review is submitted.

@github-actions github-actions Bot removed the merge-in-1-day-without-review Auto-approve countdown label Apr 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Auto-approved: No review received within 3 days. Merging now.

@github-actions github-actions Bot added the merged-without-review Auto-approve countdown label Apr 19, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved: no review received within 3 days of opening.

@github-actions github-actions Bot merged commit 9a49376 into master Apr 19, 2026
21 checks passed
@github-actions github-actions Bot deleted the feature/lock-step-reason branch April 19, 2026 08:16
@PayBas
Copy link
Copy Markdown
Contributor

PayBas commented Apr 23, 2026

Manual verification OK: image
image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add 'reason' field in the lock() step.

3 participants