If you set environment variables, they will be available for the whole build. You can set your environment variables in two different ways:
On the Environment page of your project settings you can enter the variable name and values into the corresponding fields.
We will export these environment variables to the environment your build runs via a command similar to:
') and double quotes (
"), as well as backticks (
`) in the value part of your variable are automatically escaped by prepending them with a backslash (
\). Other characters with a special meaning (e.g.
$) are not escaped automatically to allow you to use them with your environment variables. (For example to include the value of another variable.)
We export your environment variables before all other commands of your build. This is pure convenience for setting up the environment but completely equal to exporting environment variables yourself.
You can also export environment variables in your setup or test commands. So, for example, you could enter the following setup commands:
rvm use 2.0.0 export RAILS_ENV="test" bundle install
There is no difference between setting RAILS_ENV like this and adding it on the Environment page of your project settings. The advantage of putting it into the environment configuration is that secret values will not show up in your build log.
The following environment variables are exported automatically. You can use them to build your own scripts, run specific commands only if you are on a specific branch or even add flags to your CI_MESSAGE and use those flags to influence your build.
You can get the value of an environment variable by adding
$ in front of the variable name. For example:
||ID of the build in our service|
||URL of the build|
||Branch of the build|
||Commit Hash of the build|
||Name of the committer|
||Email of the committer|
||Username of the commiter in their SCM service|
||Message of the last commit for that build|
This value is hardcoded and doesn’t indicate whether a build was triggered by a pull request or not at the moment. Once we add support for building external pull requests, we will update this environment variable accordingly as well. ↩