Skip to content

feat(config): support ${env.VAR_NAME} interpolation in config files - #263

Open
mwaldheim wants to merge 1 commit into
mainfrom
feat/env-vars-in-config
Open

feat(config): support ${env.VAR_NAME} interpolation in config files#263
mwaldheim wants to merge 1 commit into
mainfrom
feat/env-vars-in-config

Conversation

@mwaldheim

Copy link
Copy Markdown
Contributor

Problem

Fixes #243

Config files couldn't reference environment variables, so plugin args had to hardcode secrets or rely on a single shared token env var — which collides when multiple provider plugins (e.g. GitHub + GitLab) are configured in the same pipeline.

Fix

Any string value in the config can now reference ${env.VAR_NAME}, expanded from the raw file bytes before format-specific parsing (YAML/TOML/JSON) — so it works uniformly across all three formats:

plugins:
  - uses: "@semrel/provider-gitlab"
    args:
      token: "${env.GITLAB_RELEASE_TOKEN}"

Undefined variables produce a clear error naming every missing variable, rather than silently substituting an empty string — a missing token is almost always a mistake, not an intentional empty value.

Testing

  • Added TestLoadConfig_EnvVarExpansion and TestLoadConfig_EnvVarExpansion_Undefined
  • go test ./pkg/config/... passes
  • Updated .semrel.yaml.example with usage docs

Different provider plugins (GitHub, GitLab, etc.) each expect their
own token env var, which previously collided when multiple providers
were configured. Config values can now reference ${env.VAR_NAME},
expanded from the raw file content before format-specific parsing
(YAML/TOML/JSON), so each plugin's args can point at a distinct
environment variable.

Undefined variables produce a clear error naming every missing
variable, rather than silently substituting an empty string.

Fixes #243

Signed-off-by: mwaldheim <31657644+mwaldheim@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow using env vars in config files

1 participant