# Use exposed ENV variable from plugin as argument for another plugin

**URL:** <https://forum.buildkite.community/t/use-exposed-env-variable-from-plugin-as-argument-for-another-plugin/2222>\
**Category:** General\
**Created:** [September 8, 2022, 8:45am UTC](https://forum.buildkite.community/t/use-exposed-env-variable-from-plugin-as-argument-for-another-plugin/2222 "2022-09-08T08:45:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gus-asm](https://avatars.discourse-cdn.com/v4/letter/g/9f8e36/32.png) [@gus-asm](https://forum.buildkite.community/u/gus-asm)\
**Post date:** [September 8, 2022, 8:45am UTC](https://forum.buildkite.community/t/use-exposed-env-variable-from-plugin-as-argument-for-another-plugin/2222/1 "2022-09-08T08:45:05Z")

</div>

Hi everyone,

I’ve been trying to figure out a way to get my pipeline working for quite sometime, but no luck.

Basically I am using docker-compose to build the environment but due to be importing some private npm packages on my project, I need to pass the environment variable as an argument, but I can’t find a way to get it working.

Here is an example of the code and plugins I am trying to use.

```auto
- name: ":docker: :yarn: Build CI Container"
    key: build-ci
    plugins:
      - seek-oss/aws-sm#v2.3.1:
          env:
            NPM_TOKEN:
              secret-id: "arn:aws:secretsmanager:...."
              json-key: ".npm_token"
      - docker-compose#v3.8.0:
          build: ci
          image-repository: ....
          args:
            - "NPM_TOKEN=${NPM_TOKEN}"

```

**seek-oss/aws-sm** exposes the secret for me as an environment variable, but on **docker-compose** I need to use as an argument the NPM\_TOKEN environment variable.

Hopefully someone can help me.

Cheers  
Gus

---

<div class="post-metadata">

**Author:** ![cwmaier-grapl](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cwmaier-grapl](https://forum.buildkite.community/u/cwmaier-grapl)\
**Post date:** [September 8, 2022, 2:52pm UTC](https://forum.buildkite.community/t/use-exposed-env-variable-from-plugin-as-argument-for-another-plugin/2222/2 "2022-09-08T14:52:39Z")

</div>

I think you probably need to use the `env` key on the Docker Compose plugin (see the second example at [GitHub - buildkite-plugins/docker-compose-buildkite-plugin: 🐳⚡️ Run build scripts, and build + push images, w/ Docker Compose](https://github.com/buildkite-plugins/docker-compose-buildkite-plugin#example)).

---

<div class="post-metadata">

**Author:** ![jeremy](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/jeremy/32/1040_2.png) [@jeremy](https://forum.buildkite.community/u/jeremy)\
**Post date:** [September 8, 2022, 6:50pm UTC](https://forum.buildkite.community/t/use-exposed-env-variable-from-plugin-as-argument-for-another-plugin/2222/3 "2022-09-08T18:50:19Z")

</div>

@gus-asm Welcome to the community!

@cwmaier-grapl’s suggestion is correct, you’ll need to ensure that the values exposed in the `seek-oss/aws-sm` plugin are available to your containers using the `env` key in the example they provided there.

---

<div class="post-metadata">

**Author:** ![gus-asm](https://avatars.discourse-cdn.com/v4/letter/g/9f8e36/32.png) [@gus-asm](https://forum.buildkite.community/u/gus-asm)\
**Post date:** [September 8, 2022, 7:19pm UTC](https://forum.buildkite.community/t/use-exposed-env-variable-from-plugin-as-argument-for-another-plugin/2222/4 "2022-09-08T19:19:37Z")

</div>

Thanks @jeremy and @cwmaier-grapl , I’ve tried initially using the env, but env are only used on run mode, not on build mode :(

```auto
` `env` or `environment` (optional, run only)

A list of either KEY or KEY=VALUE that are passed through as environment variables to the container.`

```

---

<div class="post-metadata">

**Author:** ![twometresteve2](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@twometresteve2](https://forum.buildkite.community/u/twometresteve2)\
**Post date:** [September 8, 2022, 10:45pm UTC](https://forum.buildkite.community/t/use-exposed-env-variable-from-plugin-as-argument-for-another-plugin/2222/5 "2022-09-08T22:45:57Z")

</div>

Is this another case of needing a double-dollar to stop the environment variable from being interpolated? Try:

```auto
          args:
            - "NPM_TOKEN=$$NPM_TOKEN"

```

---

<div class="post-metadata">

**Author:** ![twometresteve2](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@twometresteve2](https://forum.buildkite.community/u/twometresteve2)\
**Post date:** [September 8, 2022, 10:49pm UTC](https://forum.buildkite.community/t/use-exposed-env-variable-from-plugin-as-argument-for-another-plugin/2222/6 "2022-09-08T22:49:55Z")

</div>

…I’ve also ended up taking a whacky approach in Dockerfiles in the past, passing ARGs to ENVs. It pickles my noodle every time I have to think about it, but with enough time I can convince myself it makes sense. It goes something like:

```auto
ARG NPM_TOKEN
ENV NPM_TOKEN=$NPM_TOKEN

```

Don’t know if this will help, but give it a go - it could be useful one day anyway!
