Bitrise Android Environment Variables

Developers security best practices rule number one is: don’t add API tokens into GitHub. Inject the API tokens during CI (Continuous Integration) process to secure the tokens. Tutorial shows how to pass Bitrise environment variables as arguments to build.gradle.

This is part of a series of tutorials for building Android Continuous Integration and Continuous Delivery (CI/CD) with Bitrise.

Bitrise Env Vars

String testEnv = System.getenv("TEST_ENV") as String ?: "testEnv"// Access variable from Java classes
defaultConfig {
buildConfigField STRING, "TEST_ENV", "\"$testEnv\""
}
public static final String testEnv = BuildConfig.TEST_ENV;

Bash script

#generates date in mmddyy format
# DATE=`date +"%m%d%y"`
DATE=`date +"%Y%m%d"`
BITRISE_DATE=$DATE
#creates date environment variable
envman add --key BUILD_START_DATE --value $BITRISE_DATE
echo BUILD_START_DATE

Bitrise Secrets

software engineer, read, swim, travel. apps: https://goo.gl/rDuuQw https://goo.gl/15GvfE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store