Pass Jenkins Environment Variables to Unity3dBuilder


I am using Jenkins with the Unity3dBuilder plugin, and I would like to pass the current build number to Unity as a command line argument. I know Jenkins has a built in environment variable for this (BUILD_NUMBER), I am just wondering how to pass it to Unity.

Right now my command line parameters look like this:

-quit -batchMode -executeMethod Build.BuildAndroid -buildNumber %BUILD_NUMBER%

However, when I trace the debug output I don’t get the Jenkins build number, I just get a string containing “%BUILD_NUMBER%”. Anyone have an idea how I can do this?


Since you launch Unity.exe from the Jenkins environment the Unity process will inherit all the environment variables, so you can use System.Environment.GetEnvironmentVariable to read any variable you like.

I managed to figure this one out on my own :slight_smile: The command line parameters had to look like this:

-quit -batchMode -executeMethod Build.BuildAndroid -buildNumber "$BUILD_NUMBER"