bug: Buildkite plugin argument environment variable naming unexpected
- Dominant language
- Go
- Stars
- 1.1k
- Forks
- 378
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 74
Description
I recently noticed that the naming scheme described in the [Writing Plugins documentation](https://buildkite.com/docs/plugins/writing#step-2-add-a-plugin-dot-yml) is not always accurate. Namely, the naming convention for plugin arguments exported as environment variables appears to change based on the repository name length. Because we use full length URLs to reference our plugins, I expect the naming convention to follow what the documentation says here:

However, this is not always the case. Below I have pasted an example to illustrate what I mean.
In example number 1, I have a plugin named repository-one. The plugin in the pipeline.yaml appears as follows:
```
[2022-08-23T01:36:43Z] plugins:
--
| [2022-08-23T01:36:43Z] - ssh://git@github.com//repository-one.git#:
| [2022-08-23T01:36:43Z] command:
```
The environment variable for the argument "command" is exported as "BUILDKITE_PLUGIN_REPOSITORY_ONE_GIT_COMMAND" which follows the naming scheme I would expect.
In example number 2, I have a plugin named repository-two-buildkite-plugin. The plugin in the pipeline.yaml appears as follows:
```
[2022-08-26T22:48:37Z] plugins:
--
| [2022-08-26T22:48:37Z] - ssh://git@github.com//repository-two-buildkite-plugin.git#:
| [2022-08-26T22:48:37Z] command:
```
However, in this example the environment variable for the argument "command" is exported as "BUILDKITE_PLUGIN_REPOSITORY_TWO_COMMAND". This is very different from what the docs say above.
Is there some complication in the underlying logic that determines what the plugin arguments will be named when they are exported as environment variables? My hypothesis is that the naming convention may have changed somehow because the second example plugin repo name was too long. I would love to get some clarity on this, as this behavior was very unexpected and hard to debug, and I want to make sure this won't change arbitrarily on us down the road and break our pipelines.
NOTE: the repositories names are substituted with placeholders above, but the names follow the regex:
- `repository-one` -> `[a-z]{9}-[a-z]{7}`
- `repository-two-buildkite-plugin` -> `[a-z]{9}-[a-z]{4}-buildkite-plugin`
Contributor guide
Research direction
Start with the Writing Plugins documentation and the two pipeline.yaml examples, reproducing the environment-variable naming for the short and -buildkite-plugin repository names. No source file or test entry point is identified in the issue; done means determining the naming rule and making the implementation and documentation agree so the behavior is predictable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- ci-cd
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100