jenkinsci / jenkinsci/lockable-resources-plugin
Allow agent-specific resources or using environment variables in resource names (in UI config & Job DSL)
- Dominant language
- Java
- Stars
- 99
- Forks
- 205
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 8
Description
Creating the config via UI or Job DSL, it's not possible to refer to environment variables.
We're running multiple agents, and if a port (like 8080) gets reserved in one agent, it shouldn't block builds on other agent.
To tackle this, I'm using `NODE_NAME` environment variable in pipeline scripts, e.g.:
```groovy
lock("${env.NODE_NAME}-port-8080") {
...
}
```
That works.
Unfortunately, what doesn't work, is if you attempt to do that same in non-pipeline setup:

This doesn't evaluate the environment variable in the build time, and the locked name remains as literal `${NODE_NAME}-port-8080`.
Two potential solutions:
1) Allow using environment names
2) Add a flag for resource to be declared as "agent-specific" (so that the resource can be reserved _per_-agent)
Contributor guide
Assessment
This issue has not been assessed yet.