How to Access Environment Variables with Code
Overview
When a user provides input via Template Variables, or you pass values to your script using environment variables, you'll want to make sure that you can access these values in your code. This how to guide will walk you through the steps to access environment variables.
When accessing the contents of an environment variable in your code, we recommend storing it as a variable so it can be continuously used.
Steps
For this example, our environment variable will be named OPERATOR_A
.
Navigate to the location of your code (local, GitHub, etc.)
Select the language your code is written in from the tabs below.
Python
import os
os.environ.get('OPERATOR_A','default value')
Bash
${OPERATOR_A}
Node
process.env.OPERATOR_A;