Unity Build Automation enables running a post-build shell script to access build artifacts for tasks like uploading or automation. Users specify the script path in the Advanced Settings tab. A sample script outputs the build artifact path, converting it for Windows if needed. Additional resources cover environment variables, advanced options, and platform-specific scripts.
Symptoms:
I would like to access my build artifact on a Build Automation machine either for automatic upload to a storefront or to automate some part of the build process.
Resolution (setting up a post-build-script):
- Unity Build Automation allows users to execute a shell script after the checkout and before the build is executed.
- To set a post-build script to run, under the Advanced Settings tab of the build configuration, enter the file name (and path from the root of the project) in the post-build script field.
- The following post-build script shows an example of how to access and output the path directly to your build artifact, on either a Windows or MacOS builder.
Sample Post-Build Bash Script
#!/bin/bash
#This is a sample that will simply output the path to the build artifact
echo "START"
PLAYER_PATH=$UNITY_PLAYER_PATH
#IF we are using a Windows Builder and using the path to pass it to a native Windows application we need to properly convert the cygwin player path to windows format
if [[ "$BUILDER_OS" == "WINDOWS" ]]; then
PLAYER_PATH=$(cygpath -wa "$UNITY_PLAYER_PATH")
fi
echo "$PLAYER_PATH"
Additional Information