Setting plugin properties from environment

This probably applies other things too, but currently I’m wondering if this is possible.

I’m trying to use the docker-login plugin GitHub - buildkite-plugins/docker-login-buildkite-plugin: 🐳 Login to Docker registries
and I want to supply the username from an environment variable.

The environment variable is defined on the agent.

steps:
  - command: ./run_build.sh
    plugins:
      - docker-login#v2.0.1:
          username: $MY_USER_FROM_ENV
          password-env: MY_DOCKER_LOGIN_PASSWORD

Can this be done?

(In general I often struggle when resolving environment variables in pipelines)

Hi @thomas,

Welcome to the community!
Apologies for the delayed response.

You can do what you posted, or you can use the environment variable BUILDKITE_PLUGIN_DOCKER_LOGIN_USERNAME defined in the plugin. For the latter, you shouldn’t use username on the plugin invocation. For example:

steps:
  - command: ./run_build.sh
    plugins:
      - docker-login#v2.0.1:
          password-env: MY_DOCKER_LOGIN_PASSWORD

You can find more information about environment variables in pipelines here.

Hope this helps!

Cheers,