How to set custom environment variables?

Here's some screenshots for an example.

In the environments set up (same for staging & production, except that the value of testvariable in production is "prod"):

In the resource (same set up for staging & prod):

In the app:

Vs when in staging: