Skip to content

Add updateLock pipeline step for resource management#980

Merged
mPokornyETM merged 4 commits intomasterfrom
feature/updateLock-step
Apr 3, 2026
Merged

Add updateLock pipeline step for resource management#980
mPokornyETM merged 4 commits intomasterfrom
feature/updateLock-step

Conversation

@mPokornyETM
Copy link
Copy Markdown
Contributor

Summary

This PR adds a new \updateLock\ pipeline step that allows pipelines to dynamically manage lockable resources without using the Jenkins UI.

Features

  • Create resources: \updateLock(resource: 'name', createResource: true)\
  • Delete resources: \updateLock(resource: 'name', deleteResource: true)\
  • Set labels (replace all): \updateLock(resource: 'name', setLabels: 'label1 label2')\
  • Add/remove labels: \updateLock(resource: 'name', addLabels: 'new', removeLabels: 'old')\
  • Set note: \updateLock(resource: 'name', setNote: 'Updated by pipeline')\

Example Usage

\\groovy
pipeline {
agent any
stages {
stage('Setup') {
steps {
// Create a resource if it doesn't exist
updateLock(resource: 'my-resource', createResource: true, setLabels: 'env-test')
}
}
stage('Use') {
steps {
lock('my-resource') {
echo 'Using the resource'
}
}
}
stage('Cleanup') {
steps {
// Optionally delete the resource
updateLock(resource: 'my-resource', deleteResource: true)
}
}
}
}
\\

Validation

  • setLabels cannot be combined with addLabels or removeLabels
  • deleteResource cannot be combined with createResource or any modification options
  • Resources cannot be deleted while locked, queued, or reserved

Prior Art

This is a fresh implementation based on the original design from PR #305 by @gaspardpetit, which became stale after 4+ years. Closes #305.


Testing

Automated Tests

  • 15 new tests in \UpdateLockStepTest.java\ covering all functionality
  • All tests passing: \mvn test -Dtest=UpdateLockStepTest\

Manual Testing Steps

\\�ash
mvn hpi:run
\
Then in Jenkins:

  1. Create a Pipeline job
  2. Use the example script above
  3. Verify resources appear/disappear in Manage Jenkins → Lockable Resources
  4. Test label modifications show correctly in the UI
  5. Test that deleting a locked resource fails with appropriate error

Performance Impact

  • Minimal: Step runs outside hot paths
  • Uses existing \LockableResourcesManager\ synchronization patterns
  • Single \save()\ call per execution (same as existing steps)
  • No new background threads or scheduled tasks

@mPokornyETM mPokornyETM requested a review from a team as a code owner March 31, 2026 14:07
@github-actions github-actions Bot added java Pull requests that update Java code localization tests frontend labels Mar 31, 2026
@mPokornyETM
Copy link
Copy Markdown
Contributor Author

I can confirm that ma locale developer tests (on windows with Java 25) are OK

@mPokornyETM mPokornyETM added the merge-in-2-days-without-review Auto-approve countdown label Mar 31, 2026
@github-actions github-actions Bot added docs merge-in-1-day-without-review Auto-approve countdown and removed merge-in-2-days-without-review Auto-approve countdown labels Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

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

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
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
@github-actions github-actions Bot force-pushed the feature/updateLock-step branch from ff0dd32 to 8f6c10e Compare April 2, 2026 11:32
@github-actions github-actions Bot removed the merge-in-1-day-without-review Auto-approve countdown label Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

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 3, 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 enabled auto-merge (squash) April 3, 2026 08:13
@mPokornyETM mPokornyETM disabled auto-merge April 3, 2026 11:52
@mPokornyETM mPokornyETM merged commit 9657f1d into master Apr 3, 2026
15 checks passed
@mPokornyETM mPokornyETM deleted the feature/updateLock-step branch April 3, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants