Artifakt environment variables are available during application runtime. This allows you to customize an environments behavior or to use information you don’t want to save in your repository.
We know that an application must be able to run on several environments in parallel: development environments (on local or non-local machines), test environments, production environments, etc. If all these environments are based on the same source code, specific configurations are required for each of them. For example, the access credentials to your payment processor will be different between the test environments and your production.
This specific configuration must be stored in environment variables. Unlike other methods, such as configuration files, environment variables are unlikely to be accidentally revealed in your Git repository. In addition, this method allows you to change the configuration of each environment in isolation.
To add custom variables on an environment, go to Project → Settings → Application. The variables defined will be specific to this environment. Please note that the defined variables will be specific to the modified environment.
Configuring environment variables
An environment variable defined as "Masked" will not be displayed in the logs, unlike other environment variables.
In order to offer a high level of flexibility, Artifakt also allows you to define environment variables at the job level.
These variables are specific to the current job, which means that they will only be accessible in the execution context of this job.
The following variables are automatically set and available during build step and runtime. These variables cannot be overwritten.
Environment variables defined at the environment level are available:
- inside the containers
- when custom callbacks are triggered (
- while executing any job
Environment variables defined at the job level are available:
- while executing the current job
- when custom callbacks are triggered (if any) (
echo 'My environment name is ' . $_ENV["ARTIFAKT_ENVIRONMENT_NAME"];