Lando: How to pass environment variables to the platform.sh build hook?

Created on 2 Oct 2020  路  3Comments  路  Source: lando/lando

When using the platformsh recipe, lando executes the build hook defined in the .platformsh.app.yml configuration.

We have a pretty typical build step where we have to set an npm token to authenticate to a private npm registry, which looks like this:

npm config set //gitlab.com/api/v4/packages/npm/:_authToken ${NPM_TOKEN}

NPM_TOKEN is an environment variable which, for deployment on platform.sh, is set in the platform.sh web console and therefore is available when deploying to platform.sh.

When lando executes the build hook in the process of setting up a project, this variable seems not to be set in the context of where the build hook is executed, neither does lando read/pass/forward the environment variables from the current user session.

How would I forward or set environment variables locally for a lando project, so that the build hook has them available?

It's important to have a solution which lets me pass/set the variables without hard-coding them in the project files.

Thanks a lot for help/input on this, I really appreciate it!

platformsh

All 3 comments

@thasmo we are still talking about how exactly we want to handle envvars that are set in the platform web ui

@thasmo so after some discussion i dont think there is a good and reliable way to grab the envvars from platform and automatically inject them into lando so we are likely going to add some UX and docs on how best to handle this.

@thasmo this is what we are going to do for now
https://docs.lando.dev/config/platformsh.html#environment-variables

Was this page helpful?
0 / 5 - 0 ratings