Available environment variables

The following tables contain a list of environment variables for Unity Build Automation.

System

System environment variables control the behavior of the system and locations to resources installed. All variables are set and can be used in both Pre-Build and Post-Build Scripts.

VariableDescription
ANDROID_HOMELocal path to the Android Lib
ANDROID_NDK_ROOTLocal path to the Android NDK Root directory
BUILDER_OSThe operating system type that the build is running on. MAC or WINDOWS.
CCD_BINARY_PATHthe local path to the Cloud Content Delivery binary executable
HOMEDRIVEThe homedrive location
HOMEPATHRelative path to the home directory
OUTPUT_DIRECTORYThe path to the directory containing the output of the build process
PLASTIC_CM_PATHThe path to the Plastic CLI. If you use a Windows environment, you may want to convert to the Cygwin path to ensure that the path is valid.
PLATFORM_HOSTthe host of the Build Service API. EX/ usersvc-live.cloud.unity3d.com
PROJECT_DIRECTORYThe path to the root directory of the project to build
SCM_MAX_RETRIESMax number of retries that will be attempted when checking out source code
UNITY_EXEthe location of the unity engine executable
UPM_REGISTRYUrl of the Unity Package Manager
UPM_SERVER_ENABLEDWhen set to true, the default, will start a UPM Server on the agent
UPM_SERVER_EXEPath to the Unity Package Manager Server executable
UPM_SERVER_PORTPort that the UPM Server runs at
USERPROFILEThe user home location on the OS
WEBGL_STREAMING_ENABLEDWhen set to true, the default, the path to the StreamingAssets for a WebGL project is excluded from the list of paths to archive
WORKSPACEthe local path on the agent where all folders for a given build target are created. For example /opt/workspace/workspace

Build

Build environment variables relate to and control the execution of a build. Below is the list of general build variables. Build variables associated with a specific execution of a part of the build process are categorized in their section. Some variables may not be set before running a Unity build. We recommended checking for their value before attempting to use them.

VariableDescription
BACKTRACE_ENABLEDWhen set to "true", the default, enables error backtracing to be logged
BUILD_PLATFORMThe type of target being built
BUILD_TARGETThe ID of the UCB build-target
BUILD_REVISIONThe current revision of the source code that is going to be built.
BUILDCFG_FILEThe local path to the build config file
BUILDCFG_TARGETThe name (or id) of the target being built
BUILDJOB_CACHEThe type of files to cache when a build completes. Default is "library". Can only be set to "workspace" via the Admin UI. If using a dedicated builder is set to local
CLEAN_BUILDWhen set to true will not pull the cached library or workspace. When using git, will run a git clean. When using Perforce, will do a p4 forcesync.
IS_BUILDERSet to true when running on a build agent. False when running locally
LOG_VERBOSESet to '1' when the verbose option is passed to xcode projects
ORG_IDThe id of the UCB organization
PARENT_BUILD_GUIDThe primary artifact for this build will be downloaded and re-signed. Only set when re-signing an already built artifact
PREVIOUS_SUCCESSFUL_BUILD_REVISIONThe last revision of the target that was built successfully
PROJECT_IDThe id of the UCB project
SCM_BRANCHThe name of the branch to build
SCM_REVISIONSpecific commit hash to checkout. Only set when specified in the build configuration
SCM_HOSTThe host url for a Source Control Manager
SCM_USERThe username for checking out code from an SCM
SKIP_UPLOAD_ARTIFACTSWhen set to '1' will skip uploading the built artifacts to UCB
UCB_BUILD_NUMBERBuild Number for the specific target being built
XCARCHIVE_PATHthe local path to the Xcode Archives file ex/ '~/Library/Developer/Xcode/Archives/something.xcarchive

Cloud Content Delivery

These variables are available only when CCD_ENABLED is set to true, based on the build configuration.

VariableDescription
CCD_BUCKET_IDID of the bucket to upload the content to. Defined by the build configuration
CCD_CREATE_RELEASEWhen set to "true" will create a release from the latest version of the bucket. Defined by the build configuration.
CCD_ENABLEDWhen set to "true", will use Cloud Content Delivery. Defined by build configuration
CCD_PRESERVE_BUCKETWhen set to true will not delete the existing contents in a bucket. Defineed by the build configuration
CCD_STRIP_REMOTE_PATHWhen set to 'true' will preserve the bucket as well as upload the files directly to the root instead of at a folder level. Defined by the build configuration.

Fastlane

Fastlane environment variables control the behavior of fastlane

VariableDescription
FASTLANE_USERThe App Store Connect / Apple Developer Portal user for use with fastlane
FASTLANE_VERBOSEWhen set to 'true' will enable verbose logging when executing fastlane commands triggered.
FL_NOTARIZE_ASC_PROVIDERWWDR team id for the provider
FL_NOTARIZE_USE_NOTARYTOOLWhen using xcode 13 and this is set to true, it will use the Xcode notary tool when notarizing with fastlane
FL_NOTARIZE_USERNAMEThe App Store Connect / Apple Developer Portal user for use with fastlane

Perforce

VariableDescription
P4_CLEANUPCLIENTWhen set to "true" will run a deleteclient when checking out code from Perforce repositories
P4_SSLWhen set to "true" P4 will use SSL when communicating with the server
P4CLIENTThe P4 Client to use when performing operations against a P4 SCM
P4PORTThe port that the P4 SCM is running on
P4USERThe username to checkout code from P4 with

UVCS (Previously Plastic SCM)

VariableDescription
PLASTIC_AUTH_TYPEThe method used to authenticate with the Plastic SCM
PLASTIC_ENCRYPTION_METHODThe type of encryption on the Plastic SCM

Unity

VariableDescription
MONO_XMLSERIALIZER_THSSet to "No" which will not use the THS XML Serializer for Mono builds with Unity
UNITY_EXTRA_PARAMSExtra parameters that will be passed to the Unity Editor when running in batch mode
UNITY_PLAYER_PATHThe local path to the Unity Player
UNITY_PLAYER_PATH_DATAthe local path to the Unity Player Data file for Windows or Mac builds
UNITY_PLAYER_PATH_DEBUG_SYMBOLSthe local path to the Unity Player Debug Symbols for Android builds
UNITY_PLAYER_PATH_DSYMthe local path to the Unity Player Debug Symbols for iOS builds
UNITY_SHADER_COMPILER_RETRY_COUNTSet to "3". The number of retry attempts when compiling shaders in Unity
UNITY_VERSIONThe version of Unity the build will run
UNITY_VERSION_DIFFTrue if the version of Unity for this build is different from the last build

There are two additional dynamically configured environment variables based on the build configuration and output. Due to the nature of how these work, the pattern for determining the name of the environment variable will be provided.

VariableDescriptionPattern
UNITY_PLAYER_PATH_#{architecture}The local path to the Unity Player file for a given architecture.The #{architecture} represents a place holder value for the target architecture of a build. EX/ if one of the output architectures was x86 then the environment variable would be UNITY_PLAYER_PATH_X86
UNITY_PLAYER_PATH_#{obb_file_type}_OBBThe local path to the Unity Player OBB fileThe #{obb_file_type} represents a place holder value for various OBB files. EX/ the file is name example.file.obb then the environment variable would be UNITY_PLAYER_PATH_FILE_OBB