#Hey guys ๐Ÿ‘‹ How can I pass a secretEnv

1 messages ยท Page 1 of 1 (latest)

modern sparrow
#

๐Ÿ‘‹ this works amigo

{
  core {
    image(ref: "alpine") {
      exec(
        input: {args: ["printenv", "VERCEL_TOKEN"], secretEnv: {name: "VERCEL_TOKEN", id: "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"}}
      ) {
        stderr
        stdout
      }
    }
  }
}```
#

you need to call the addSecret query before that to get the correct secretId

storm tartan
#

Thanks

modern sparrow
#

take into account that ${VERCEL_TOKEN} is a shell expansion, so you need to use a shell to call the vercel CLI on order to send the token as a CLI argument

#

the vercel CLI doesn't pick up a token env variable automatically?

storm tartan
#

you mean with those args for instance 'sh', '-c' ?

storm tartan
modern sparrow
dire garden
#

vercel doesnโ€™t seem thrilled about being wrapped

#

do they have a typescript client library maybe?

storm tartan
#

I wanted to create an extension with it

#

by using axios

dire garden
#

I think your options are:

  1. Execute a shell script and pass token env to that, the `${TOKEN}โ€ will work as @modern sparrow explained

  2. use a client library instead

  3. find a way to configure the CLI that we havenโ€™t seen

#

I would start with 1) since youโ€™re not far

storm tartan
#
  core {
    image(ref: "index.docker.io/dockette/vercel") {
      exec(
        input: {
          args: [
            "sh"
            "-c"
            "vercel"
            "--name"
            "dagger_io"
            "deploy"
            "./out"
            "-t"
            "VERCEL_TOKEN"
            "--scope"
            "dagger"
            "-c"
          ]
          mounts: [{ fs: $sourceAfterBuild, path: "/src" }]
          workdir: "/src"
          secretEnv: { name: "VERCEL_TOKEN", id: $tokenSecretId }
        }
      ) {
        stderr
        stdout
      }
    }
  }
#

this doesn't work

modern sparrow
#

VERCEL_TOKEN still needs the ${} thingy

storm tartan
#

oh

#

sorry

modern sparrow
#

๐Ÿค—

storm tartan
#

๐Ÿ˜

#

sorry I'm taking care of both kids at the same time ๐Ÿ˜‚

#

challenging

modern sparrow
#

np!

dire garden
#

He doesnโ€™t understand (yet)

storm tartan
#

ahahah

storm tartan
#

with ${} I've got ReferenceError: VERCEL_TOKEN is not defined

#

I'll come back later when kids will sleep. Thanks guys for your help ๐Ÿ™

modern sparrow
storm tartan
#

So the solution is to use the following syntax $VERCEL_TOKEN. The ${} seems to be interpretated by JS. Thanks @floral forge ๐Ÿ™‚

dire garden
#

When you stack too many abstractions on top of each other: JS -> graphql -> buildkit -> bash -> JS -> REST