Is a Netlify Site Name available automatically as an environment variable?

It seems like everything else under the sun is:

I wondering for use in Netlify Build Plugins, to determine the URL to the build log.

Hi @moop-moop,

Yes, all the environment variables are documented in the page you referenced.
You can use the following environment variables to determine the build or Site’s URL.

When it comes to the Site name, I don’t think this is currently exposed as an environment variable. Are the URL-related environment variables above enough for your use case, or do you also need the Site name?

Thanks @ehmicky that’s what I thought.
My interest is that the “Site Name” and the “Build ID” make up the URL to the build log.
I wanted to include that URL (which is dynamic for auto deployed pull requests) in the GitHub status details link for the plugin I am working on.

I think the DEPLOY_URL might work for this purpose. Please let me know if it does not :slight_smile:

I think it will, just need to parse it to extract the sitename.
https://5b243e66dd6a547b4fee73ae–petsof.netlify.app

Also looks like BUILD_ID is not the ID in the path to the URL, so it’s probably DEPLOY_ID

Yes it is the deploy ID.
Netlify Build itself is actually parsing the BUILD_URL to retrieve the site name as well :slight_smile:
Currently the site name is not available as an environment variable.
Which URL are you trying to build using the site name?

Maybe it’s officially called the deploy log:

For example:
https://app.netlify.com/sites/foo-bar-096f2a/deploys/5ed14ad123a96a04e3a52dc2

Hi @moop-moop,

I have added a feature request to our back-end team to add a SITE_NAME environment variable in builds. Would this make it easier to solve your problem?

1 Like

Hi @moop-moop,

This is now available! :tada:
Please see the documentation for the SITE_NAME and SITE_ID here.