Search code examples
androidioscontinuous-integrationbitrise

Bitrise default environment variables


Where I can find full list of Bitrise default environment variables with actual values?

I can see list of variables in Select variable dialog:

Select variable image

but there's no possibility to check their values. I don't want to print all of them in command line using echo and check their values. Would be nice to have this information in bitrise.io documentation, which is missing at the moment.

I've found some bitrise* repositories in github, and in the source code of steps I was able to check some default values for environment variables. It's still not the desired result.


Solution

  • Why we don't have docs for the values: because it can change any time. The point of Environment Variables is that you can reference things where the value might change. The variable's meaning remains the same, but the value might change.

    For example, $BITRISE_SOURCE_DIR refers to the main working directory, which (by default) is the code directory (where your code is git cloned). On the OS X stack it's usually /Users/vagrant/git, on the Android Docker stack it's usually /bitrise/src; but we don't guarantee that the location won't change in the future, and you can change this location as well.

    Another important thing is, if you use the bitrise CLI to run your automation on your own Mac, the $BITRISE_SOURCE_DIR environment variable will be set by bitrise to the directory you call bitrise from, which is usually the same directory as on bitrise.io VMs, the one with your code.

    Why is this important? If you use the $BITRISE_SOURCE_DIR environment in your script instead of a hardcoded value, it'll refer to the same thing (the source code directory path), no matter which environment you use to run your automation.