@UnknownTester404
So in the context of passing the value of DK_IMAGE
from meta-data into the plugin, you’ll need to ensure that you are getting the meta-data with the buildkite-agent meta-data get
command, at which point you would be able to reference the value of DK_IMAGE
directly in your pipeline YAML.
In the step that uploads this pipeline yaml to Buildkite with buildkite-agent pipeline upload
, you would have an environment
hook (you can use other hooks that run before command
, but for this example I’m going to use environment) which checks for the meta-data with key DK_IMAGE
, and then downloads that meta-data and exports it in the job environment to be referenced by the pipeline upload command. I’ll break this down below with some examples:
Let’s assume for this example I’ve set the meta-data for this build already with this command:
buildkite-agent meta-data set "DK_IMAGE" "foo:1.2.3"
and I have the following pipeline yaml in my repo under
.buildkite/pipeline.yaml
:
plugins:
- plugin-1:
- docker#vx.x.x:
image: $DK_IMAGE
propagate-environment: true
mount-buildkite-agent: true
workdir: /app
volumes:
- /app/node_modules
environment:
- ????
And I have the following environment
hook configured on my agent:
# Environment hook
#!/bin/bash
if [ buildkite-agent meta-data exists "DK_IMAGE" ]; then
export DK_IMAGE=$(buildkite-agent meta-data get "DK_IMAGE")
fi
What ends up happening is when buildkite-agent pipeline upload
runs, the value of $DK_IMAGE
is parsed and is set in the pipeline YAML received by Buildkite, which will look like this:
plugins:
- plugin-1:
- docker#vx.x.x:
image: foo:1.2.3
propagate-environment: true
mount-buildkite-agent: true
workdir: /app
volumes:
- /app/node_modules
environment:
- ????
It’s important to note that you cannot access meta-data directly in your pipeline YAML (via a declaration like{metaenv.DK_IMAGE}
), but you can access it via the meta-data command mentioned above. Some other valuable reading would be our docs around environment variables, as there are some nuances that are good to be aware of!
Hopefully the above helps, but feel free to reach out with any further questions