jenkinsci / jenkinsci/lockable-resources-plugin

Allow agent-specific resources or using environment variables in resource names (in UI config & Job DSL)

Open
#276 1 comment 0 reactions 0 assignees View on GitHub
documentation good first issue Triage variables for lock aspects
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:

![image](https://user-images.githubusercontent.com/94327/144584069-17fa2f3a-61c1-441d-8cc7-67a166105fc0.png)

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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.