Environment variables

Environment variables help manage your build script tasks. You can call pre-defined variables or create your own.

Pre-Defined variables

General variables Description
APPCENTER_BUILD_ID The unique identifier for the current build
APPCENTER_BRANCH Name of the branch that is being built from
APPCENTER_SOURCE_DIRECTORY Location of the source code on the build machine
APPCENTER_OUTPUT_DIRECTORY Location where the build results are stored in
APPCENTER_TRIGGER What triggered the build, was it manual or continuous by push

iOS specific
APPCENTER_XCODE_PROJECT Selected Xcode project
APPCENTER_XCODE_SCHEME Selected Xcode scheme

Android specific
APPCENTER_ANDROID_VARIANT Selected Android variant
APPCENTER_ANDROID_MODULE Selected Android module

UWP specific
APPCENTER_UWP_SOLUTION Selected solution
APPCENTER_UWP_CONFIGURATION Selected configuration

Xamarin specific
APPCENTER_XAMARIN_PROJECT Selected project
APPCENTER_XAMARIN_CONFIGURATION Selected configuration

React Native specific
APPCENTER_REACTNATIVE_PACKAGE Selected package

Variables declared in Build Configuration

Custom environment variables allow you to define sensitive information that is required for your build without checking them into your repository. You can create your environment variables in the build configuration and use them in your build. For example, to access an API key, a webhook token, or other secrets.

Note

'Platform' is reserved from use as an environment variable.

The build configuration showing custom environment variables in different states

Encrypting variables

Values of variables are encrypted by clicking on the lock icon, which obfuscates them in the build configuration & logs. Encrypted values aren't editable once they're saved, but they can be deleted & re-created.

Non-encrypted values can be encrypted at any time.

Access the variables

Pre-set environment variables can be consumed during the build process. Depending on the toolset you're using, the syntax is different.

Note

The correct way to consume environment variables depends on the toolchain used.

Build scripts

In the build scripts, you can access the variables with the following syntax depending on whether you're using Bash or Powershell.

  • Bash

    $ENVIRONMENT_VARIABLE
    
  • Powershell

    $env:ENVIRONMENT_VARIABLE
    

NuGet.config for Xamarin or UWP

If you're building a Xamarin or UWP app, you might want to connect to a private NuGet feed, which requires authentication. In the NuGet.config file, you can consume the variables you've defined. For more details about the usage of credentials in your NuGet.config file, read the reference documentation.

<packageSourceCredentials>
  <MyAuthNuget>
    <add key="Username" value="%USER_VARIABLE%" />
    <add key="ClearTextPassword" value="%PASSWORD_VARIABLE%" />
  </MyAuthNuget>
</packageSourceCredentials>

build.gradle for Android

For Android apps, you can access your variables in the build.gradle config. For more details, please read the Gradle Tips and Recipes documentation.

buildConfigField("String", "API_KEY", "\"${System.env.API_KEY}\"")