Feeding meta-data to a docker plugin command

Hello, I’m trying to get metadata “foobar” to feed into docker command, but the command is either escaped or any environment variables I set are ignored. Example (which is obviously truncated) below:

steps:
  - label: ":emoji: Run command in docker image"
    key: action-service
    plugins:
      - docker#v5.4.0:
          image: "registry.company.com/company-internal/tool-we-built:v1.0.11"
          command: ["command", "subcommand", "--flag", '$(buildkite-agent meta-data get foobar)']

How is one supposed to do this?

Hi @masper!

Welcome to the community! You’ll probably want to specifically name the environment variable you want to be propagated in the environment property of the plug-in: GitHub - buildkite-plugins/docker-buildkite-plugin: 🐳📦 Run any build step in a Docker container

Best!

How? I’m trying to feed it metadata and those aren’t propagated to an environment variable?

For context: I’ve tried this

environment:
  - "FOOBAR=$(buildkite-agent meta-data get foobar)"

and it was ignored, hence “any environment variables I set are ignored”

For people who stumble on this, the method I found workable is this:

FOODBAR=$$(buildkite-agent meta-data get foobar) buildkite-agent pipeline upload ./.buildkite/another-pipeline.yml

in another-pipeline.yml

steps:
  - label: ":emoji: Run command in docker image"
    key: action-service
    plugins:
      - docker#v5.4.0:
          image: "registry.company.com/company-internal/tool-we-built:v1.0.11"
          environment:
            - "FOOBAR=$FOOBAR"
          command: ["command", "subcommand", "--flag", "$FOOBAR"]

It’s not ideal since you can’t just directly use the plugin, but it’s the “buildkite” way of doing it