Xcode Server environment variables

Xcode Server defines a number of built-in environment variables, which you may use in Run Script build phases that execute as part of your integration, in pre-integration triggers, and in post-integration triggers. Information provided by some of these variables is useful when making Xcode Server API requests. For more information, see Xcode Server API Reference.

In addition to the built-in Xcode Server environment variables, you can also define custom environment variables when you create a bot or on the Arguments pane, when you edit a bot.

Variable

Description

XCS

The value of this variable is always 1. A script can check this value to determine if it’s running in the context of Xcode Server.

Available in Xcode 7 and later.

XCS_BOT_NAME

The name of the bot being run.

Available in Xcode 7 and later.

XCS_BOT_ID

The ID of the bot. Bot IDs can be used in Xcode Server API requests.

Available in Xcode 7 and later.

XCS_BOT_TINY_ID

A short version of a bot ID. Some Xcode Server API requests use this information.

Available in Xcode 7 and later.

XCS_INTEGRATION_ID

The ID of the integration. Bot IDs can be used in Xcode Server API requests.

Available in Xcode 7 and later.

XCS_INTEGRATION_TINY_ID

A short version of an integration ID. Some Xcode Server API requests use this information.

Available in Xcode 7 and later.

XCS_INTEGRATION_NUMBER

The number of times the integration has been run.

Available in Xcode 7 and later.

XCS_INTEGRATION_RESULT

A string indicating the result of the integration, such as warnings, analyzer-warnings, succeeded, test-failures, build-errors, and canceled. This variable is intended for use in post-integration trigger scripts.

Available in Xcode 7 and later.

XCS_SOURCE_DIR

The top-level directory containing source code repositories for Xcode Server. For the path to a repository itself, see XCS_PRIMARY_REPO_DIR.

Available in Xcode 7 and later.

XCS_OUTPUT_DIR

The top-level directory where resources, including logs and products, are stored during integration.

Available in Xcode 7 and later.

XCS_DERIVED_DATA_DIR

The derived data directory. Xcode Server builds in a non-standard location, so this directory is bot-specific.

Available in Xcode 7 and later.

XCS_XCODEBUILD_LOG

The path to an output file produced by the xcodebuild commands run during the integration.

Available in Xcode 7 and later.

XCS_ARCHIVE

The path to the .xarchive file, if archiving occurred during the integration.

Available in Xcode 7 and later.

XCS_PRODUCT

The path to the .app, .ipa, or .package file, if a product was exported from an archive during the integration.

Available in Xcode 7 and later.

XCS_ERROR_COUNT

The total number of errors encountered during the integration.

Available in Xcode 7 and later.

XCS_ERROR_CHANGE

The change in error count since the previous integration. This value can be negative.

Available in Xcode 7 and later.

XCS_WARNING_COUNT

The total number of warnings encountered during the integration.

Available in Xcode 7 and later.

XCS_WARNING_CHANGE

The change in warning count since the previous integration. This value can be negative.

Available in Xcode 7 and later.

XCS_ANALYZER_WARNING_COUNT

The total number of static analyzer warnings encountered during the integration.

Available in Xcode 7 and later.

XCS_ANALYZER_WARNING_CHANGE

The change in static analyzer warning count since the previous integration. This value can be negative.

Available in Xcode 7 and later.

XCS_TEST_FAILURE_COUNT

The total number of test failures encountered during the integration.

Available in Xcode 7 and later.

XCS_TEST_FAILURE_CHANGE

The change in test failure count since the previous integration. This value can be negative.

Available in Xcode 7 and later.

XCS_TESTS_COUNT

The total number of tests performed by the integration.

Available in Xcode 7 and later.

XCS_TESTS_CHANGE

The change in test count since the previous integration. This value can be negative.

Available in Xcode 7 and later.

XCS_THINNED_PRODUCTS_PLIST

The path to a property list file (.plist) describing thinned .ipa files exported and their corresponding variants. This property list file only exists when thinning is performed.

Available in Xcode 8 and later.

XCS_THINNED_PRODUCTS_PATH

The directory containing any thinned .ipa files exported during the integration.

Available in Xcode 8 and later.

XCS_PRIMARY_REPO_DIR

The path to the source code repository for the Xcode project or workspace being integrated. For the parent directory containing the source code repositories for Xcode Server, see XCS_SOURCE_DIR.

Available in Xcode 8 and later.

XCS_PRIMARY_REPO_BRANCH

The branch of the primary source code repository used to check out the project or workspace being integrated. Only used when checking out a branch.

Available in Xcode 8 and later.

XCS_PRIMARY_REPO_TAG

The tag of the primary source code repository used to check out the project or workspace being integrated. Only used when checking out a tag.

Available in Xcode 8 and later.

XCS_PRIMARY_REPO_REVISION

The remote source control revision number of the commit used to check out the project or workspace being integrated out of the primary source code repository. Only used when not checking out a branch or a tag.

Available in Xcode 8 and later.

See alsoContinuous integration using Xcode ServerCreate bot triggers