cirrus-ci-docs
cirrus-ci-docs copied to clipboard
Environment variable override for manually created builds
Expected Behavior
I expected that triggering a manual build with "override build configuration" passed would cause it to append/only override the part of the build configuration that was passed to, i.e. when passing an env var, I expected it to only override that single env var no matter if I'm using .cirrus.star
or .cirrus.yaml
.
Build configuration
Example 1:
-
.cirrus.yml
example_task:
container:
image: ubuntu:latest
script: echo "${CUSTOM_VAR:-default value}"
Example 2:
-
.cirrus.star
load("github.com/cirrus-modules/helpers", "container", "script", "task")
def main(ctx):
return [
task("example", container("ubuntu:latest"), {}, [script('echo "${CUSTOM_VAR:-default value}"')])
]
Real Behavior
The override only worked when using .cirrus.star
- nothing from .cirrus.yaml
is part of the manually triggered build.
Example tasks:
- using
.cirrus.star
(properly working):- on push: https://cirrus-ci.com/task/4793416981676032
- manual: https://cirrus-ci.com/task/5384766030610432
- using
.cirrus.yml
(not working correctly):- on push: https://cirrus-ci.com/task/5343097331646464
- manual: https://cirrus-ci.com/build/6549067172937728
Related Info
This is a (tick one of the following):
- [ ] Website issue
- Link to page:
- [x] Task issue
- OS: any
- Task name:
example
- Script/cache name (if applies): N/A
I was unsure if this isn't perhaps a feature request but since it works with .cirrus.star
, it might be that it's just a bug.
The configOverride
GraphQL field overrides the whole YAML configuration, not just a part of it.
The Starlark configuration is left untouched since the Starlark option was introduced relatively recently to the createBuild()
GraphQL mutation. Perhaps we need to add a starlarkConfigOverride
field too (/cc @fkorotkov).
Regarding the ability to partially overwrite a configuration (like env
), you can use Starlark for that. Note that the resulting YAML configuration from .yml
/.yaml
and Starlark are merged together, so the fields that are not overwritten by Starlark will remain in the resulting map, e.g.:
env:
COLOR: red
WARMTH: hot
# Override from Starlark
env:
COLOR: yellow
...will result in:
env:
COLOR: yellow
WARMTH: hot
Regarding the ability to partially overwrite a configuration (like
env
), you can use Starlark for that. Note that the resulting YAML configuration from.yml
/.yaml
and Starlark are merged together, so the fields that are not overwritten by Starlark will remain in the resulting map, e.g.:
I want to partially overwrite a configuration from the manual build UI so the ability to override from Starlark doesn't help here:
What I want is to be able to use both .cirrus.yaml
and .cirrus.star
files and be able to partially overwrite a configuration (or just have any way at all to specify some custom parameters for the build) from the manual build UI. I suppose that this makes it a feature request then since it seems that the current UI has a different purpose.