Environment variables inside plugin netlify.toml arguments

Hello everyone :wave:

Is there a way to use environment variables inside deploy plugin config?

For instance, we are using Netlify Plugin Lighthouse to run page speed checks on our production website every time there’s a new deploy to main.

However, we also need to run those tests on branch preview deploys so we can have an idea of whether the scores got better or worse.

Our plugin config is currently like this:

[[plugins]]
  package = "@netlify/plugin-lighthouse"

  [[plugins.inputs.audits]]
    url = "https://getcircuit.com"
  [[plugins.inputs.audits]]
    url = "https://getcircuit.com/teams"
  [[plugins.inputs.audits]]
    url = "https://getcircuit.com/teams/blog"

Is there a way to make something like this work?

[[plugins]]
  package = "@netlify/plugin-lighthouse"

  [[plugins.inputs.audits]]
    url = "${DEPLOY_PRIME_URL}"
  [[plugins.inputs.audits]]
    url = "${DEPLOY_PRIME_URL}/teams"
  [[plugins.inputs.audits]]
    url = "${DEPLOY_PRIME_URL}/teams/blog"
1 Like

Hey @vtrpldn,

Sorry for the delay. I don’t believe there’s a built-in way to do that, but you can fork the plugin and directly use the environment variables in that: Create Build Plugins | Netlify Docs

It’s not an ideal way, but could possibly work.