Creating Environment Variables
Environment variables can be created in all the environments of a pipeline directly from the Pipeline record or, alternatively, in a specific environment from the Environment Variables related list in the Environment record.
Let’s see how you can create an environment variable using these two options.
Creating an Environment Variable from a Pipeline Record
- Navigate to a Pipeline record.
- Click on the drop-down menu in the upper right corner and select Manage Environment Variables.
- Click on New and give your variable a name. For example, if you want to create a variable to store username values, you can name it Username:
- Once created, provide the specific values for each of the environments in the pipeline:
To remove a variable from the grid, you can click on the Del link. This will result in deleting the variable in all the environments. If you add a new variable to the grid, the variable will be created in all the environments with an empty value.
You can also mass edit the grid. Once saved, all the records will be updated. The renaming of variables is fully supported.
Creating an Environment Variable in an Environment Record
- Navigate to the Environment Variables related list in an existing Environment record.
- Click on New to create a new variable:
- Give your variable a name, e.g., URL, and set a value, e.g., https://copado-uat-dev-ed.lightning.force.com/.Please note that environment variable values do not support RegEx or the * character.
- The Scope field allows you to specify where a particular variable is applied. If you want the variable to be applied to all occurrences of the value across all files, you can leave this field empty. Otherwise, if you want the variable to be applied to a specific metadata type, for instance, you can use this field to define the scope of the variable.
Scope supports a serialized list of values separated by the semicolon (;) delimiter.
The scope options are the following:
Use this expression if you want the variable to be applied to a specific metadata type
If you use this expression, the variable will be applied to a specific item within a particular metadata type
Custom settings: You can choose to get variables applied to all custom settings
Custom settings: You can choose to get variables applied to a specific custom setting
Custom Labels: The variable will be applied to all components.
Note: You cannot specify the component since custom labels are stored in a singular file.
The variable will be applied to Apex steps
Use this expression if you want the variable to be applied to Data deployment steps
All objects and a specific apex class
Copado enforces a constraint on environment variables with unique scope-values and its behavior is based on the following hierarchy structure:
- If the same value is used in two different environment variables with overlapping scope, the more specific scope will win.
- If the scope is empty for the same value in two or more environment variables, no replacement will be done. The value should be unique if no scope is defined.
- Scope and value combination should be unique across all environment variables.
For more information about environment variables, please refer to the Environment Variables article.