Managing Environment Variables
Creating Environment Variables
You can create up to 200 environment variables per platform, project, pipeline, and app. When you reach this limit, the create button becomes unavailable, preventing you from creating new environment variables. |
-
Choose whether you want to create a global, project, pipeline, or app environment variable:
-
Click Projects from the primary navigation menu.
By default, the All Projects page opens with the list of existing projects.
-
Click Projects from the primary navigation menu.
By default, the All Projects page opens with the list of existing projects. -
Click a project in the list to open it.
By default, the Jobs page opens with the list of existing jobs.
-
Click Projects from the primary navigation menu.
By default, the All Projects page opens with the list of existing projects. -
Click a project in the list to open it.
By default, the Jobs page opens with the list of existing jobs. -
Click Pipelines from the secondary navigation menu to open the project’s pipeline library.
-
Click a pipeline in the list to open it and access its details.
The pipeline Overview page opens.
-
Click Projects from the primary navigation menu.
By default, the All Projects page opens with the list of existing projects. -
Click a project in the list to open it.
By default, the Jobs page opens with the list of existing jobs. -
Click Apps from the secondary navigation menu to open the project’s app library.
-
Click an app in the list to open it and access its details.
The app Overview page opens.
-
-
Click Environment variables from the secondary navigation menu.
The page opens with the list of existing environment variables. -
Click Create variable to create a new environment variable.
A panel opens that you can edit. -
Enter the required information.
-
Environment variable names is mandatory. It has to start with a letter and can be up to 128 characters, including alphanumeric characters (a-z) (A-Z) (0-9) and underscores (_).
-
The environment variable value can be up to 2,048 characters.
-
The description is optional and have no restrictions, but it is a good practice to add it and keep it short and informative.
-
You can select the option is password if your value is a password and must be hidden.
⇒ Existing environment variables that do not follow these rules are flagged as errors.
-
-
Click Save to confirm the creation.
The created environment variable appears in the list of the corresponding scope, that is, either in the global, project, pipeline, or app Environment variables page.
Deleting an Environment Variable
-
Click the environment variable you want to delete.
You must be on the Environment variables page of the specific level you want to delete. In other words, you cannot delete a pipeline environment variable from the project Environment variables page. To delete a pipeline environment variable, you must be on the Environment variables page of the desired pipeline. To delete an app environment variable, you must be on the Environment variables page of the desired app, and so on. -
In the right-hand panel that opens, click Delete.
A confirmation message appears. -
Click Delete again to confirm the deletion.
Be careful, there is no progress bar to cancel the deletion once it is confirmed. Besides, deleting variables used by jobs or custom apps can cause them problems.
Editing Environment Variables
-
Choose whether you want to create a global, project, pipeline, or app environment variable:
-
Click Projects from the primary navigation menu.
By default, the All Projects page opens with the list of existing projects.
-
Click Projects from the primary navigation menu.
By default, the All Projects page opens with the list of existing projects. -
Click a project in the list to open it.
By default, the Jobs page opens with the list of existing jobs.
-
Click Projects from the primary navigation menu.
By default, the All Projects page opens with the list of existing projects. -
Click a project in the list to open it.
By default, the Jobs page opens with the list of existing jobs. -
Click Pipelines from the secondary navigation menu to open the project’s pipeline library.
-
Click a pipeline in the list to open it and access its details.
The pipeline Overview page opens.
-
Click Projects from the primary navigation menu.
By default, the All Projects page opens with the list of existing projects. -
Click a project in the list to open it.
By default, the Jobs page opens with the list of existing jobs. -
Click Apps from the secondary navigation menu to open the project’s app library.
-
Click an app in the list to open it and access its details.
The app Overview page opens.
-
-
Click Environment variables from the secondary navigation menu.
The page opens with the list of existing environment variables. -
Click the variable you want to change in the list.
A panel opens that you can edit. -
Change the information as needed.
-
Environment variable names is mandatory. It has to start with a letter and can be up to 128 characters, including alphanumeric characters (a-z) (A-Z) (0-9) and underscores (_).
-
The environment variable value can be up to 2,048 characters.
-
The description is optional and have no restrictions, but it is a good practice to add it and keep it short and informative.
-
You can select the option is password if your value is a password and must be hidden.
⇒ Existing environment variables that do not follow these rules are flagged as errors.
-
-
Click Save to save your changes.
Overriding Environment Variables
-
Navigate to:
-
Click Projects from the primary navigation menu.
By default, the All Projects page opens with the list of existing projects. -
Click a project in the list to open it.
By default, the Jobs page opens with the list of existing jobs.
-
Click Projects from the primary navigation menu.
By default, the All Projects page opens with the list of existing projects. -
Click a project in the list to open it.
By default, the Jobs page opens with the list of existing jobs. -
Click Pipelines from the secondary navigation menu to open the project’s pipeline library.
-
Click a pipeline in the list to open it and access its details.
The pipeline Overview page opens.
-
Click Projects from the primary navigation menu.
By default, the All Projects page opens with the list of existing projects. -
Click a project in the list to open it.
By default, the Jobs page opens with the list of existing jobs. -
Click Apps from the secondary navigation menu to open the project’s app library.
-
Click an app in the list to open it and access its details.
The app Overview page opens.
-
-
Click Environment variables from the secondary navigation menu.
The page opens with the list of existing environment variables. -
Click the variable you want to override in the list.
A panel opens that you can edit. -
At the bottom of the panel, click Override in this project/pipeline/app.
-
Enter the required information for the corresponding scope.
-
Click Save to save your changes.
The overridden environment variable still exists at the top level and is still applied, except in the current project, pipeline, or app, where it will be applied with the new value.
Creating and Modifying Variables in a Job Output in a Pipeline
-
Enable the Variables setting in your pipeline from the pipeline Overview page or from its Edit mode.
-
Click Variables.
A panel opens with the existing variables in a code block. -
Click the switch to enable the modification of variables in pipeline execution.
-
-
To use variables in the code of your jobs, you must write in text form the variables you want to use in other jobs in the
output-vars.properties
file.-
Create the
output-vars.properties
execution variables output file in the/workdir
folder that is located in the local file system of your job. -
Write your variables in text form in this file.
You can either write:
-
One variable per line with the following patterns:
<VARIABLE_NAME>=<variable_value>
. -
Several variables on one line, separated by the special character
\n
:<VARIABLE_NAME>=<variable_value>\n<VARIABLE_NAME>=<variable_value>\n<VARIABLE_NAME>=<variable_value>
.
Variable names is mandatory. It has to start with a letter and can be up to 128 characters, including alphanumeric characters (a-z) (A-Z) (0-9) and underscores (_).
Example 1. Defining variables for a Bash jobTo define the following variables in a Bash job:
<VARIABLE_NAME>
<variable_value>
myVariable_1
Hello everybody
myVariable_2
2023
Other_variable
444
Write the following code line in the command line of your job:
echo -ne 'myVariable_1=Hello everybody\nMyVariable_2=2023\nOther_variable="444"' > /workdir/output-vars.properties
Refer to the documentation of the technology used in your job to know how to write to a file. Example 2. How to read variables?To read variables in your job’s code, you can use:
-
<VARIABLE_NAME>
: Corresponds to the last value written by the previous job, which is read when the current job starts. -
<INIT_VARIABLE_NAME>
: Corresponds to the pipeline initialization value, that is, the value of the corresponding environment variable readable by the pipeline. -
<jobAlias_VARIABLE_NAME>
: Corresponds to the output value written by the job referenced by the alias.
For example, to read the variables of the previous example, write the following code line in the command line of your job:
echo $myVariable_1 echo $INIT_myVariable_1 echo $jobAlias_myVariable_1 echo $myVariable_2 echo $INIT_myVariable_2 echo $jobAlias_myVariable_2 echo $Other_variable echo $INIT_Other_variable echo $jobAlias_Other_variable
The output variables will be retrieved in the next jobs during pipeline execution and used as environment variables.
-
-