jenkinsci / jenkinsci/lockable-resources-plugin
Add lockNode() Pipeline step
- Dominant language
- Java
- Stars
- 99
- Forks
- 205
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 8
Description
### Summary
Add a dedicated Pipeline step `lockNode()` for node-exclusive locking semantics.
### Motivation
Users currently maintain a Jenkins node plus a separate lockable resource with the same name/labels. This is redundant and error-prone. A purpose-built step clarifies intent and improves UX.
### Proposed usage
```groovy
lockNode("agent-1") {
// exclusive use
}
lockNode(label: "hw-s7", quantity: 1) {
node(env.LOCKED_NODE) {
// run
}
}
```
### Behavior (v1)
Provide node-specific environment variables such as `LOCKED_NODE`. Prefer online nodes when selecting candidates.
### Implementation approach (v1)
Start as syntactic sugar over existing locking mechanics (exact mapping to NodesMirror/resources to be decided).
### Acceptance criteria
- Works with node name and node label
- Enforces exclusivity
- Does not require users to manually keep duplicate configuration (or clearly documents what is required)
### Tests
- JenkinsRule pipeline tests for exclusivity + env vars
- Label-based selection tests
Contributor guide
Assessment
This issue has not been assessed yet.