Closed secureoptions closed 3 years ago
Hi @secureoptions!
This happens because the environment in the YML is being evaluated on upload, so the value of "username" is empty because the build doesn't actually run that input step yet. Meta-data cannot be interpolated directly from the pipeline.yml at runtime. The meta-data store can only be accessed from within a command step.
We suggest uploading the first part of that pipeline then have another pipeline upload steps that upload the remaining of the pipeline because then it would get the value. For example like this:
steps:
- block: "Get import details"
fields:
- text: "What is your name?"
key: myvar
- command: >
export USERNAME="$(buildkite-agent meta-data get 'myvar')" && echo '
steps:
- env:
USERNAME: \$USERNAME
command: echo \\\$USERNAME' | buildkite-agent pipeline upload
label: upload
I would recommend running the shell command with a script, but this would be the idea.
You can find more information about this here.
Cheers,
Hi Team,
I'm trying to understand the best way to pass user input fields from block steps into the docker plugin. Something like this for example:
The problem I run into is that ${USERNAME} is interpreted literally as
$(buildkite-agent meta-data get "username")
instead of the actual username. Do you have any other suggestions for adding more vars from block input?