Home
Support Forums

Environment Variable Contexts Not Working

Hello there,
For some reason my environment variables are not being picked up based on their appropriate context. The echoed $CONTEXT in my build command is showing the correct value but the scoped environment variable are never applied.

[build.environment]
    REACT_APP_TEST_VALUE = "default"

[context.production]
    REACT_APP_TEST_VALUE = "production"

[context.staging]
    REACT_APP_TEST_VALUE = "staging"

[context.branch-deploy]
    REACT_APP_TEST_VALUE = "branch-deploy"

Based on the code given above, the only environmental variable that is successfully applied is build.environment. Any help would be greatly appreciated!

Additional Info:

  • Using create-react-app

Site name: heatwav-admin.netlify.app

Hi @fireteam99,

Do you have some specific deploys that we can look at for each of the above contexts? We could investigate with regards to those instead of trying to find out the deploys with the problem.

For sure, below is an example of a build where the environmental variables failed Netlify App

As you can see, the context is being determined properly but the scoped environmental variable was not being applied. I also updated my description with new information.

11:29:44 PM: Build ready to start
11:29:46 PM: build-image version: 3bcb38c35508b42e9121d4badfe6d8c66fd7a3f0
11:29:46 PM: build-image tag: v4.3.2
11:29:46 PM: buildbot version: fdfb4991fe9d90ac67dcc6a49b9c69b58441874a
11:29:46 PM: Fetching cached dependencies
11:29:46 PM: Starting to download cache of 253.7MB
11:29:49 PM: Finished downloading cache in 3.066656484s
11:29:49 PM: Starting to extract cache
11:29:59 PM: Finished extracting cache in 10.169972542s
11:29:59 PM: Finished fetching cache in 13.272196077s
11:29:59 PM: Starting to prepare the repo for build
11:29:59 PM: Preparing Git Reference refs/heads/master
11:30:00 PM: Parsing package.json dependencies
11:30:01 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'echo 'toml context & context.production' && echo $CONTEXT && REACT_APP_TEST_VALUE=special npm run build' versus 'npm run build' in the Netlify UI
11:30:01 PM: Starting build script
11:30:01 PM: Installing dependencies
11:30:01 PM: Python version set to 2.7
11:30:01 PM: Started restoring cached node version
11:30:04 PM: Finished restoring cached node version
11:30:04 PM: v16.11.1 is already installed.
11:30:05 PM: Now using node v16.11.1 (npm v8.0.0)
11:30:05 PM: Started restoring cached build plugins
11:30:05 PM: Finished restoring cached build plugins
11:30:05 PM: Attempting ruby version 2.7.2, read from environment
11:30:06 PM: Using ruby version 2.7.2
11:30:07 PM: Using PHP version 8.0
11:30:07 PM: Started restoring cached node modules
11:30:07 PM: Finished restoring cached node modules
11:30:07 PM: Started restoring cached go cache
11:30:07 PM: Finished restoring cached go cache
11:30:07 PM: go version go1.16.5 linux/amd64
11:30:07 PM: go version go1.16.5 linux/amd64
11:30:07 PM: Installing missing commands
11:30:07 PM: Verify run directory
11:30:09 PM: ​
11:30:09 PM: ────────────────────────────────────────────────────────────────
11:30:09 PM:   Netlify Build                                                 
11:30:09 PM: ────────────────────────────────────────────────────────────────
11:30:09 PM: ​
11:30:09 PM: ❯ Version
11:30:09 PM:   @netlify/build 18.17.1
11:30:09 PM: ​
11:30:09 PM: ❯ Flags
11:30:09 PM:   baseRelDir: true
11:30:09 PM:   buildId: 6168f5a872e7830009f0c73b
11:30:09 PM:   deployId: 6168f5a872e7830009f0c73d
11:30:09 PM: ​
11:30:09 PM: ❯ Current directory
11:30:09 PM:   /opt/build/repo
11:30:09 PM: ​
11:30:09 PM: ❯ Config file
11:30:09 PM:   /opt/build/repo/netlify.toml
11:30:09 PM: ​
11:30:09 PM: ❯ Context
11:30:09 PM:   production
11:30:09 PM: ​
11:30:09 PM: ────────────────────────────────────────────────────────────────
11:30:09 PM:   1. build.command from netlify.toml                            
11:30:09 PM: ────────────────────────────────────────────────────────────────
11:30:09 PM: ​
11:30:09 PM: $ echo 'toml context & context.production' && echo $CONTEXT && REACT_APP_TEST_VALUE=special npm run build
11:30:09 PM: toml context & context.production
11:30:09 PM: production
11:30:09 PM: > heatwav-admin@0.2.0 build
11:30:09 PM: > react-scripts build
11:30:11 PM: Creating an optimized production build...
11:31:15 PM: Compiled successfully.
11:31:15 PM: 
11:31:15 PM: File sizes after gzip:
11:31:16 PM: Creating deploy upload records
11:31:15 PM:   472.97 KB  build/static/js/2.e388f16d.chunk.js
11:31:15 PM:   28.38 KB   build/static/css/2.629319f3.chunk.css
11:31:15 PM:   16.7 KB    build/static/js/main.34cd593e.chunk.js
11:31:15 PM:   2.93 KB    build/static/css/main.dd1d9abb.chunk.css
11:31:15 PM:   781 B      build/static/js/runtime-main.9d000b1f.js
11:31:15 PM: The project was built assuming it is hosted at /.
11:31:15 PM: You can control this with the homepage field in your package.json.
11:31:15 PM: The build folder is ready to be deployed.
11:31:15 PM: You may serve it with a static server:
11:31:15 PM:   npm install -g serve
11:31:15 PM:   serve -s build
11:31:15 PM: Find out more about deployment here:
11:31:15 PM:   https://cra.link/deployment
11:31:16 PM: ​
11:31:16 PM: (build.command completed in 1m 6.8s)
11:31:16 PM: ​
11:31:16 PM: ────────────────────────────────────────────────────────────────
11:31:16 PM:   2. Deploy site                                                
11:31:16 PM: ────────────────────────────────────────────────────────────────
11:31:16 PM: ​
11:31:16 PM: Starting to deploy site from 'build'
11:31:16 PM: Creating deploy tree 
11:31:16 PM: 7 new files to upload
11:31:16 PM: 0 new functions to upload
11:31:16 PM: Site deploy was successfully initiated
11:31:16 PM: ​
11:31:16 PM: (Deploy site completed in 553ms)
11:31:16 PM: ​
11:31:16 PM: ────────────────────────────────────────────────────────────────
11:31:16 PM:   Netlify Build Complete                                        
11:31:16 PM: ────────────────────────────────────────────────────────────────
11:31:16 PM: ​
11:31:16 PM: (Netlify Build completed in 1m 7.4s)
11:31:16 PM: Starting post processing
11:31:16 PM: Post processing - HTML
11:31:16 PM: Post processing - header rules
11:31:17 PM: Caching artifacts
11:31:17 PM: Started saving node modules
11:31:17 PM: Finished saving node modules
11:31:17 PM: Started saving build plugins
11:31:17 PM: Finished saving build plugins
11:31:16 PM: Post processing - redirect rules
11:31:17 PM: Started saving pip cache
11:31:17 PM: Post processing done
11:31:17 PM: Finished saving pip cache
11:31:17 PM: Started saving emacs cask dependencies
11:31:17 PM: Finished saving emacs cask dependencies
11:31:17 PM: Started saving maven dependencies
11:31:17 PM: Finished saving maven dependencies
11:31:17 PM: Started saving boot dependencies
11:31:17 PM: Site is live ✨
11:31:17 PM: Finished saving boot dependencies
11:31:17 PM: Started saving rust rustup cache
11:31:17 PM: Finished saving rust rustup cache
11:31:17 PM: Started saving go dependencies
11:31:17 PM: Finished saving go dependencies
11:31:17 PM: Build script success
11:32:14 PM: Finished processing build request in 2m28.083959212s

Update

I noticed what while the scoped environment variables were not being applied, the scoped build command was. What I ended up doing was prepending the env vars in front of the build commands.

[context.production]
   command = "URL='prod.com' npm run build'"
[context.branch-deploy]
   command = "URL='stage.com' npm run build'"

I also noticed that the β€œcustom branch name” context was not working. I have a staging branch configured for branch deploy; however, during stage builds, the context is showing up as branch-deploy and not staging.

[context.staging] # <-- DOES NOT WORK
   command = "URL='stage.com' npm run build'"
[context.branch-deploy] # <-- WORKS
   command = "URL='dev.com' npm run build'"

Example branch build log:

11:15:40 PM: Waiting for other deploys from your team to complete. Check the queue: https://app.netlify.com/teams/fireteam99/builds
11:16:34 PM: Build ready to start
11:16:36 PM: build-image version: 3bcb38c35508b42e9121d4badfe6d8c66fd7a3f0
11:16:36 PM: build-image tag: v4.3.2
11:16:36 PM: buildbot version: fdfb4991fe9d90ac67dcc6a49b9c69b58441874a
11:16:36 PM: Fetching cached dependencies
11:16:37 PM: Starting to download cache of 244.3MB
11:16:37 PM: Finished downloading cache in 1.059213553s
11:16:37 PM: Starting to extract cache
11:16:46 PM: Finished extracting cache in 8.795980148s
11:16:46 PM: Finished fetching cache in 9.93734516s
11:16:46 PM: Starting to prepare the repo for build
11:16:47 PM: Preparing Git Reference refs/heads/staging
11:16:47 PM: Parsing package.json dependencies
11:16:48 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'echo 'toml context' && echo $CONTEXT && npm run build' versus 'npm run build' in the Netlify UI
11:16:48 PM: Starting build script
11:16:48 PM: Installing dependencies
11:16:48 PM: Python version set to 2.7
11:16:48 PM: Started restoring cached node version
11:16:51 PM: Finished restoring cached node version
11:16:51 PM: v16.11.1 is already installed.
11:16:52 PM: Now using node v16.11.1 (npm v8.0.0)
11:16:52 PM: Started restoring cached build plugins
11:16:52 PM: Finished restoring cached build plugins
11:16:52 PM: Attempting ruby version 2.7.2, read from environment
11:16:53 PM: Using ruby version 2.7.2
11:16:53 PM: Using PHP version 8.0
11:16:53 PM: Started restoring cached node modules
11:16:53 PM: Finished restoring cached node modules
11:16:54 PM: Started restoring cached go cache
11:16:54 PM: Finished restoring cached go cache
11:16:54 PM: go version go1.16.5 linux/amd64
11:16:54 PM: go version go1.16.5 linux/amd64
11:16:54 PM: Installing missing commands
11:16:54 PM: Verify run directory
11:16:55 PM: ​
11:16:55 PM: ────────────────────────────────────────────────────────────────
11:16:55 PM:   Netlify Build                                                 
11:16:55 PM: ────────────────────────────────────────────────────────────────
11:16:55 PM: ​
11:16:55 PM: ❯ Version
11:16:55 PM:   @netlify/build 18.17.1
11:16:55 PM: ​
11:16:55 PM: ❯ Flags
11:16:55 PM:   baseRelDir: true
11:16:55 PM:   buildId: 6168f25b04f2a50007a67bd6
11:16:55 PM:   deployId: 6168f25b04f2a50007a67bd8
11:16:55 PM: ​
11:16:55 PM: ❯ Current directory
11:16:55 PM:   /opt/build/repo
11:16:55 PM: ​
11:16:55 PM: ❯ Config file
11:16:55 PM:   /opt/build/repo/netlify.toml
11:16:55 PM: ​
11:16:55 PM: ❯ Context
11:16:55 PM:   branch-deploy
11:16:56 PM: ​
11:16:56 PM: ────────────────────────────────────────────────────────────────
11:16:56 PM:   1. build.command from netlify.toml                            
11:16:56 PM: ────────────────────────────────────────────────────────────────
11:16:56 PM: ​
11:16:56 PM: $ echo 'toml context' && echo $CONTEXT && npm run build
11:16:56 PM: toml context
11:16:56 PM: branch-deploy
11:16:56 PM: > heatwav-admin@0.2.0 build
11:16:56 PM: > react-scripts build
11:16:58 PM: Creating an optimized production build...
11:17:56 PM: Compiled successfully.
11:17:56 PM: 
11:17:56 PM: File sizes after gzip:
11:17:56 PM:   472.97 KB  build/static/js/2.80ebe5d0.chunk.js
11:17:56 PM:   28.38 KB   build/static/css/2.629319f3.chunk.css
11:17:56 PM:   16.7 KB    build/static/js/main.82d9fc17.chunk.js
11:17:56 PM:   2.93 KB    build/static/css/main.dd1d9abb.chunk.css
11:17:56 PM:   781 B      build/static/js/runtime-main.9d000b1f.js
11:17:56 PM: The project was built assuming it is hosted at /.
11:17:56 PM: You can control this with the homepage field in your package.json.
11:17:56 PM: The build folder is ready to be deployed.
11:17:56 PM: You may serve it with a static server:
11:17:56 PM:   npm install -g serve
11:17:56 PM:   serve -s build
11:17:56 PM: Find out more about deployment here:
11:17:56 PM:   https://cra.link/deployment
11:17:56 PM: ​
11:17:56 PM: (build.command completed in 1m 0.5s)
11:17:56 PM: ​
11:17:56 PM: ────────────────────────────────────────────────────────────────
11:17:56 PM:   2. Deploy site                                                
11:17:56 PM: ────────────────────────────────────────────────────────────────
11:17:56 PM: Creating deploy upload records
11:17:56 PM: Starting post processing
11:17:56 PM: Post processing - HTML
11:17:56 PM: Post processing - header rules
11:17:56 PM: Post processing - redirect rules
11:17:57 PM: Post processing done
11:17:57 PM: Site is live ✨
11:17:56 PM: ​
11:17:56 PM: Starting to deploy site from 'build'
11:17:56 PM: Creating deploy tree 
11:17:56 PM: 0 new files to upload
11:17:56 PM: 0 new functions to upload
11:17:56 PM: Site deploy was successfully initiated
11:17:56 PM: ​
11:17:56 PM: (Deploy site completed in 134ms)
11:17:56 PM: ​
11:17:56 PM: ────────────────────────────────────────────────────────────────
11:17:56 PM:   Netlify Build Complete                                        
11:17:56 PM: ────────────────────────────────────────────────────────────────
11:17:56 PM: ​
11:17:56 PM: (Netlify Build completed in 1m 0.7s)
11:17:57 PM: Caching artifacts
11:17:57 PM: Started saving node modules
11:17:57 PM: Finished saving node modules
11:17:57 PM: Started saving build plugins
11:17:57 PM: Finished saving build plugins
11:17:57 PM: Started saving pip cache
11:17:57 PM: Finished saving pip cache
11:17:57 PM: Started saving emacs cask dependencies
11:17:57 PM: Finished saving emacs cask dependencies
11:17:57 PM: Started saving maven dependencies
11:17:57 PM: Finished saving maven dependencies
11:17:57 PM: Started saving boot dependencies
11:17:57 PM: Finished saving boot dependencies
11:17:57 PM: Started saving rust rustup cache
11:17:57 PM: Finished saving rust rustup cache
11:17:57 PM: Started saving go dependencies
11:17:57 PM: Finished saving go dependencies
11:17:57 PM: Build script success
11:18:42 PM: Finished processing build request in 2m5.732021986s

Hi @fireteam99

Using the sample file as reference have you tried setting the environment variable like

[context.production.environment]
    REACT_APP_TEST_VALUE = "production"

or

[context.production]
  environment = { REACT_APP_TEST_VALUE = "production" }

Hmmm I haven’t tried setting the key as [context.production.environment] nor have I tried setting the value as { REACT_APP_TEST_VALUE = "production" }. Did I need to append environment to context.production?

My understanding (happy to stand corrected) is yes.

For instance:

# Productions
[context.production]
   command = "URL='prod.com' npm run build'"

  [context.production.environment]
    MY_VARIABLE = "something"

# Branch
[context.branch-deploy]
   command = "URL='stage.com' npm run build'"

  [context.branch-deploy.environment]
    MY_VARIABLE = "something else"

While I don’t deal with context deploys, the same is used with build

[build]
  command = "yarn build"
  publish = "build"

  [build.environment]
    NETLIFY_USE_YARN = "true"

Ahh okay that makes a ton of sense actually. I should have read the documentation a bit closer haha. Let me give it a try right now.

@coelmay the environmental variable issue has been fixed, thanks! I’m still having an issue getting the staging context to show up though. Only branch-deploy shows up for some reason.

Quoting Deploy contexts docs

For example, a branch called staging will match a deploy context called staging .

Is your branch called staging?

Yep I have a branch named staging exactly. I’m trying to reference it as context.staging but even on builds branch-deploy shows up as the context.

I don’t have any projects with multiple branches currently such that I can test.

However, as per previously linked sample file, context.staging comes after context.branch-deploy, so if you have these the opposite way, the latter is possibly overriding the former.

So I removed branch-deploy from my toml file and replaced it with staging but the context during the build is still showing up as branch-deploy

[context.production]
    [context.production.environment]
        REACT_APP_TEST_VALUE="prod"

[context.staging]
    [context.staging.environment]
        REACT_APP_TEST_VALUE="staging"

10:05:06 PM: Build ready to start
10:05:09 PM: build-image version: 3bcb38c35508b42e9121d4badfe6d8c66fd7a3f0
10:05:09 PM: build-image tag: v4.3.2
10:05:09 PM: buildbot version: 349bc0ff8daba7d6ea8d12b21f2f782cbf97d24f
10:05:09 PM: Fetching cached dependencies
10:05:09 PM: Starting to download cache of 253.9MB
10:05:11 PM: Finished downloading cache in 2.149832286s
10:05:11 PM: Starting to extract cache
10:05:24 PM: Finished extracting cache in 13.10228388s
10:05:24 PM: Finished fetching cache in 15.309496907s
10:05:24 PM: Starting to prepare the repo for build
10:05:25 PM: Preparing Git Reference refs/heads/staging
10:05:25 PM: Parsing package.json dependencies
10:05:26 PM: Starting build script
10:05:26 PM: Installing dependencies
10:05:26 PM: Python version set to 2.7
10:05:27 PM: Started restoring cached node version
10:05:29 PM: Finished restoring cached node version
10:05:30 PM: v16.11.1 is already installed.
10:05:31 PM: Now using node v16.11.1 (npm v8.0.0)
10:05:31 PM: Started restoring cached build plugins
10:05:31 PM: Finished restoring cached build plugins
10:05:31 PM: Attempting ruby version 2.7.2, read from environment
10:05:33 PM: Using ruby version 2.7.2
10:05:33 PM: Using PHP version 8.0
10:05:33 PM: Started restoring cached node modules
10:05:33 PM: Finished restoring cached node modules
10:05:34 PM: Started restoring cached go cache
10:05:34 PM: Finished restoring cached go cache
10:05:34 PM: go version go1.16.5 linux/amd64
10:05:34 PM: go version go1.16.5 linux/amd64
10:05:34 PM: Installing missing commands
10:05:34 PM: Verify run directory
10:05:36 PM: ​
10:05:36 PM: ────────────────────────────────────────────────────────────────
10:05:36 PM:   Netlify Build                                                 
10:05:36 PM: ────────────────────────────────────────────────────────────────
10:05:36 PM: ​
10:05:36 PM: ❯ Version
10:05:36 PM:   @netlify/build 18.17.2
10:05:36 PM: ​
10:05:36 PM: ❯ Flags
10:05:36 PM:   baseRelDir: true
10:05:36 PM:   buildId: 616a3352015fad00075f9e39
10:05:36 PM:   deployId: 616a3352015fad00075f9e3b
10:05:36 PM: ​
10:05:36 PM: ❯ Current directory
10:05:36 PM:   /opt/build/repo
10:05:36 PM: ​
10:05:36 PM: ❯ Config file
10:05:36 PM:   /opt/build/repo/netlify.toml
10:05:36 PM: ​
10:05:36 PM: ❯ Context
10:05:36 PM:   branch-deploy
10:05:36 PM: ​
10:05:36 PM: ────────────────────────────────────────────────────────────────
10:05:36 PM:   1. build.command from netlify.toml                            
10:05:36 PM: ────────────────────────────────────────────────────────────────
10:05:36 PM: ​
10:05:36 PM: $ npm run build
10:05:37 PM: > heatwav-admin@0.2.0 build
10:05:37 PM: > react-scripts build
10:05:39 PM: Creating an optimized production build...
10:06:25 PM: Compiled successfully.
10:06:25 PM: 
10:06:25 PM: File sizes after gzip:
10:06:25 PM:   472.95 KB  build/static/js/2.d264bfa7.chunk.js
10:06:25 PM:   28.38 KB   build/static/css/2.629319f3.chunk.css
10:06:25 PM:   16.56 KB   build/static/js/main.4f9cd9f7.chunk.js
10:06:25 PM:   2.93 KB    build/static/css/main.dd1d9abb.chunk.css
10:06:25 PM:   781 B      build/static/js/runtime-main.9d000b1f.js
10:06:25 PM: The project was built assuming it is hosted at /.
10:06:25 PM: You can control this with the homepage field in your package.json.
10:06:25 PM: The build folder is ready to be deployed.
10:06:25 PM: You may serve it with a static server:
10:06:25 PM:   npm install -g serve
10:06:25 PM:   serve -s build
10:06:25 PM: Find out more about deployment here:
10:06:25 PM:   https://cra.link/deployment
10:06:25 PM: ​
10:06:25 PM: (build.command completed in 49.2s)
10:06:25 PM: ​
10:06:25 PM: ────────────────────────────────────────────────────────────────
10:06:25 PM:   2. Deploy site                                                
10:06:25 PM: ────────────────────────────────────────────────────────────────
10:06:25 PM: ​
10:06:25 PM: Starting to deploy site from 'build'
10:06:25 PM: Creating deploy tree 
10:06:25 PM: Creating deploy upload records
10:06:26 PM: 1 new files to upload
10:06:26 PM: 0 new functions to upload
10:06:26 PM: Site deploy was successfully initiated
10:06:26 PM: ​
10:06:26 PM: (Deploy site completed in 433ms)
10:06:26 PM: ​
10:06:26 PM: ────────────────────────────────────────────────────────────────
10:06:26 PM:   Netlify Build Complete                                        
10:06:26 PM: ────────────────────────────────────────────────────────────────
10:06:26 PM: Starting post processing
10:06:26 PM: ​
10:06:26 PM: (Netlify Build completed in 49.8s)
10:06:26 PM: Post processing - HTML
10:06:26 PM: Post processing - header rules
10:06:26 PM: Caching artifacts
10:06:26 PM: Started saving node modules
10:06:26 PM: Finished saving node modules
10:06:26 PM: Post processing - redirect rules
10:06:26 PM: Started saving build plugins
10:06:26 PM: Finished saving build plugins
10:06:26 PM: Started saving pip cache
10:06:26 PM: Finished saving pip cache
10:06:26 PM: Started saving emacs cask dependencies
10:06:26 PM: Finished saving emacs cask dependencies
10:06:26 PM: Started saving maven dependencies
10:06:26 PM: Post processing done
10:06:26 PM: Finished saving maven dependencies
10:06:26 PM: Started saving boot dependencies
10:06:26 PM: Finished saving boot dependencies
10:06:26 PM: Started saving rust rustup cache
10:06:26 PM: Finished saving rust rustup cache
10:06:26 PM: Started saving go dependencies
10:06:26 PM: Finished saving go dependencies
10:06:26 PM: Build script success
10:06:26 PM: Site is live ✨

This is unrelated but I also noticed that my branch deploys aren’t automatically published. My production branch is being automatically published though. Is there any way to make my staging branch deploy auto publish?

Which is correct, because it is a branch deploy.

Here is the deploy log for a newly created branch coelmay/netlify-react-bare/tree/staging deployed at staging–netlify-react-bare.netlify.app. It shows branch-deploy as the context even though the branch is called staging. I know it was the staging branch deployed though.

I can only assume this is simply how the build system logs out the data. It doesn’t (appear) to influence the build.

If you click the β€œBranch Deploy” at the top of the deploy details, or on the Deploys page, it should take you to the branch url e.g. staging--netlify-site-name.netlify.app. This is in addition to the preview URL.

I can only assume this is simply how the build system logs out the data. It doesn’t (appear) to influence the build.

Hmm, even so it seems like anything i have under [context.staging] is not being applied but anything under [context.branch-deploy] is. Even though staging should override branch-deploy.

Regarding the auto deploy issue, I have the setting turned on:

However during branch builds I have to manually click β€œPublish deploy” after the build finishes. If I click β€œPreview deploy” before clicking β€œPublish deploy” I get lead to a link like: https://616a3352015fad00075f9e3b--heatwav-admin.netlify.app/login. Only after clicking β€œPublish deploy” does the preview lead to staging--heatwav-admin.netlify.app.

Did you try changing the order? E.G having staging after branch-deploy

[content.branch-deploy]
  command = "..."

  [context.branch-deploy.environment]
    SOME_VARIABLE = "This is a standard branch deploy"

[content.staging]
  command = "..."

  [context.staging.environment]
    SOME_VARIABLE = "This is a staging branch deploy"

Doing this publishes the branch to the production site. Automatically publishing branches to production is (generally) not wanted as they are (often) for testing purposes.

In your last image the link β€œBranch Deploy” (if you hover over it) will show staging branch name (e.g. staging--heatwav-admin.netlify.app) while the β€œPreview deploy” link will show the preview URL (e.g. 616a3352015fad00075f9e3b--heatwav-admin.netlify.app).

Did you try changing the order? E.G having staging after branch-deploy

Yeah I tried changing the order but didn’t have any luck…

Doing this publishes the branch to the production site. Automatically publishing branches to production is (generally) not wanted as they are (often) for testing purposes.

Ahh okay that makes sense then, thanks!

I updated the netlify.toml in my staging branch, adding context.branch-deploy before. The context.staging settings were used rather than the context.branch-deploy (see deploy log and deploy preview.)

I then removed context.staging and the context.branch-deploy settings were used (see deploy log and deploy preview.)

NOTE: The difference between the two is the URL for Get the template.

If this is not occurring for you, can you share your repository, or a minimal replica, for testing.