Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cloud Build default environment variables

Discussion in 'Unity Build Automation' started by c_andrews, Jan 6, 2021.

  1. c_andrews

    c_andrews

    Joined:
    Jan 26, 2015
    Posts:
    106
    Hi, could you tell me if there is a list somewhere of what default environment variables we are able to utilise in a shell script for either the Pre or Post build.

    Currently I know about WORKSPACE, but is there any others such as
    - BUILD_TARGET_ID (Build config name e.g. android-play-store)
    - BUILD_PLATFORM (iOS, Android)

    Thanks in Advance
     
    gmgannon likes this.
  2. jaydeebee

    jaydeebee

    Joined:
    Dec 9, 2020
    Posts:
    4
    I don't have an official list either, and agree some proper specification of what's intended would be helpful.

    But in lieu of that, you can use the env command to get a list of what's set. I find it helpful to put a call to env at the top of my post-build script anyway, so the environment is logged as part of the build (note that there may be some sensitive bits in there).

    There's also a build.json file with more, which can be parsed from scripts using jq. These two commands will get your build target (used to generate the build directory) and the build platform (such as standalonewindows64), storing them in the named variables, then print them as an example:


    build_target=$(jq -r 'keys[0]' < build.json)
    build_platform=$(jq -r ".[\"${build_target}\"].platform" < build.json)
    echo "Building $build_target for $build_platform"


    If you want to just dump a pretty-printed copy of build.json in its entirety,

    jq . < build.json
     
  3. c_andrews

    c_andrews

    Joined:
    Jan 26, 2015
    Posts:
    106
    Thank you that is really useful
     
  4. gmgannon

    gmgannon

    Joined:
    Sep 24, 2020
    Posts:
    6


    Very useful thanks. Finding Cloud Build great, but documentation is thin.
     
  5. gnp89

    gnp89

    Joined:
    Jun 25, 2012
    Posts:
    36
    In case someone's curious...
    Output for "env" command in post build script:

    1710: USERDOMAIN=WIN10-PACKER-US
    1711: ChocolateyToolsLocation=C:\tools
    1712: OS=Windows_NT
    1713: LC_ALL=en_US.UTF-8
    1714: COMMONPROGRAMFILES=C:\Program Files\Common Files
    1715: PROCESSOR_LEVEL=6
    1716: RUN_DISPLAY_URL=http://172.18.252.100:8080/job/studios.gitlabcitests.default-android/1/display/redirect
    1717: PSModulePath=%ProgramFiles(x86)%\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\PowerShell
    1718: UCB_BUILD_NUMBER=9
    1719: JENKINS_URL=http://172.18.252.100:8080/
    1720: CommonProgramW6432=C:\Program Files\Common Files
    1721: USE_SHORT_PATH=true
    1722: EXECUTOR_NUMBER=0
    1723: HTTP_PROXY=
    1724: SSH_CONNECTION=10.128.10.111 47672 10.129.0.188 22
    1725: API_KEY=5ce2ecc8d50ad2ea9065c8114886453a
    1726: THOR_DEBUG=1
    1727: ANDROID_HOME=C:\Android\sdk_30_0_2
    1728: CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
    1729: LICENSE_LEGACY_ENABLED=true
    1730: _=/usr/bin/env
    1731: LANG=en_US.UTF-8
    1732: BUILD_ID=1
    1733: BUILD_CAUSE=MANUALTRIGGER
    1734: POWERSHELL_DISTRIBUTION_CHANNEL=MSI:Windows Server 2019 Datacenter
    1735: rvm_bin_path=/home/buildbot/.rvm/bin
    1736: PUBLIC=C:\Users\Public
    1737: OLDPWD=/cygdrive/c/workspace/workspace
    1738: WEBGL_STREAMING_ENABLED=true
    1739: RUN_CHANGES_DISPLAY_URL=http://172.18.252.100:8080/job/studios.gitlabcitests.default-android/1/display/redirect?page=changes
    1740: SIGNED_REQUEST_SECRET=429t81t05dMFk426X60dz513N49H19BW
    1741: rvm_version=1.29.12 (latest)
    1742: RUBY_VERSION=ruby-2.4.2
    1743: GEM_HOME=/home/buildbot/.rvm/gems/ruby-2.4.2
    1744: USYM_UPLOAD_AUTH_TOKEN=f131dad061781b5e8f8d65bb18f69d22a7fe83fd038af3ac68cb5de7f3e2a09d
    1745: USERNAME=buildbot
    1746: ChocolateyInstall=C:\ProgramData\chocolatey
    1747: JAVA_HOME=c:\Program Files\Java\jdk1.8.0_211
    1748: LOGONSERVER=\\WIN10-PACKER-US
    1749: PROCESSOR_ARCHITECTURE=AMD64
    1750: JOB_BASE_NAME=studios.gitlabcitests.default-android
    1751: WORKSPACE_TMP=BUILD_PATH/studios.gitlabcitests.default-android@tmp
    1752: LOCALAPPDATA=C:\Users\buildbot\AppData\Local
    1753: CI=true
    1754: CLASSPATH=.;
    1755: HUDSON_COOKIE=2bf069e5-0bc4-4d76-a2ac-80e80cc1375a
    1756: COMPUTERNAME=WIN10-PACKER-US
    1757: CRASH_SERVICE_URL=https://a:b@perf-events.cloud.unity3d.com/
    1758: USER=buildbot
    1759: SYSTEMDRIVE=C:
    1760: USERPROFILE=C:\Users\buildbot
    1761: PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    1762: SYSTEMROOT=C:\Windows
    1763: BUILD_NUMBER=1
    1764: MONO_XMLSERIALIZER_THS=no
    1765: PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 79 Stepping 0, GenuineIntel
    1766: WORKSPACE=BUILD_PATH/p
    1767: NVM_SYMLINK=C:\Program Files\nodejs
    1768: BUILD_REVISION=c9fa89aaef779a445383666159d4483ce2c66065
    1769: PWD=BUILD_PATH/p
    1770: HUDSON_URL=http://172.18.252.100:8080/
    1771: HOME=/home/buildbot
    1772: SSH_AGENT_PID=1742
    1773: HUDSON_SERVER_COOKIE=e3c856913a9f8f25
    1774: ANDROID_NDK_ROOT=C:\Android\ndk-r19
    1775: JOB_NAME=studios.gitlabcitests.default-android
    1776: RUN_TESTS_DISPLAY_URL=http://172.18.252.100:8080/job/studios.gitlabcitests.default-android/1/display/redirect?page=tests
    1777: CCD_BINARY_PATH=/UNITY_PATH/Unity/content-delivery/production/0.9.7_windows_ucd.exe
    1778: LICENSE_POOL_CONFIG={"clientHandshakeTimeoutSec":30,"clientConnectTimeoutSec":15,"enableFloatingApi":true,"enableEntitlementLicensing":true,"licensingServiceBaseUrl":"http://35.238.64.14:8178"}
    1779: UNITY_EXE=/cygdrive/c/Program Files/Unity/Editor/Unity.exe
    1780: PROCESSOR_REVISION=4f00
    1781: GEM_PATH=/home/buildbot/.rvm/gems/ruby-2.4.2:/home/buildbot/.rvm/gems/ruby-2.4.2@global
    1782: JOB_DISPLAY_URL=http://172.18.252.100:8080/job/studios.gitlabcitests.default-android/display/redirect
    1783: UPM_REGISTRY=https://packages.unity.com
    1784: NUMBER_OF_PROCESSORS=8
    1785: ProgramW6432=C:\Program Files
    1787: AUTOMATED_BUILD_ENGINE=true
    1788: rvm_path=/home/buildbot/.rvm
    1789: RUN_ARTIFACTS_DISPLAY_URL=http://172.18.252.100:8080/job/stud...ult-android/1/display/redirect?page=artifacts
    1790: MAIL=/var/spool/mail//buildbot
    1791: GIT_LFS_PATH=C:\Program Files\Git LFS
    1792: LICENSE_POOL_CONFIG_PATH=/cygdrive/c/ProgramData/Unity/config/services-config.json
    1793: EVENT_NOKQUEUE=1
    1794: HTTPS_PROXY=
    1795: COMSPEC=C:\Windows\system32\cmd.exe
    1796: GooGetRoot=C:\ProgramData\GooGet
    1797: UNITY_SHADER_COMPILER_RETRY_COUNT=3
    1798: APPDATA=C:\Users\buildbot\AppData\Roaming
    1799: BUILD_URL=http://172.18.252.100:8080/job/studios.gitlabcitests.default-android/1/
    1800: PLASTIC_CLCONFIGURECLIENT_PATH=/UNITY_PATH/Unity/windows/scm/plastic/PlasticSCM5/client/clconfigureclient.exe
    1801: TERM=xterm-256color
    1802: SHELL=/bin/bash
    1803: BUILDPACK_DLL_PATH=/home/buildbot/buildpack
    1804: JOB_URL=http://172.18.252.100:8080/job/studios.gitlabcitests.default-android/
    1805: BUILD_DISPLAY_NAME=#1
    1806: WINDIR=C:\Windows
    1807: UNITY_BUILDPACK_DLL_VERSION=buildpack-479e50cc.zip
    1808: BUILD_PROVIDER=GCP
    1809: ROOT_BUILD_CAUSE=MANUALTRIGGER
    1810: NVM_HOME=C:\ProgramData\nvm
    1811: rvm_prefix=/home/buildbot
    1812: ProgramData=C:\ProgramData
    1813: SHLVL=4
    1814: LIBRARY_CACHE_FILE=library_2020_3_18f1_windows
    1815: SYNCHRONOUS_SYMBOL_PROCESSING=TRUE
    1816: PROGRAMFILES=C:\Program Files
    1817: ROOT_BUILD_CAUSE_MANUALTRIGGER=true
    1818: LICENSE_POOL_ENABLED=true
    1819: ALLUSERSPROFILE=C:\ProgramData
    1820: DATADOG_METRICS_API_TOKEN=70b1c83cfdadd34d72b63d6a3960436b
    1821: DriverData=C:\Windows\System32\Drivers\DriverData
    1822: LOGNAME=buildbot
    1823: LICENSE_POOL_EXE=/cygdrive/c/Program Files/Unity/Editor/Data/Resources/Licensing/Client/Unity.Licensing.Client.exe
    1824: BACKTRACE_ENABLED=true
    1825: MY_RUBY_HOME=/home/buildbot/.rvm/rubies/ruby-2.4.2
    1826: PLASTIC_CM_PATH=/UNITY_PATH/Unity/windows/scm/plastic/PlasticSCM5/client/cm.exe
    1828: ProgramFiles(x86)=C:\Program Files (x86)
    1829: PATH=/home/buildbot/.rvm/gems/ruby-2.4.2/bin:/home/buildbot/.rvm/gems/ruby-2.4.2@global/bin:/home/buildbot/.rvm/rubies/ruby-2.4.2/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Windows/System32/OpenSSH:/cygdrive/c/ProgramData/GooGet:/cygdrive/c/Program Files/Google/Compute Engine/metadata_scripts:/cygdrive/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/cygdrive/c/Program Files/PowerShell/7:/cygdrive/c/Program Files/Google/Compute Engine/sysprep:/cygdrive/c/ProgramData/chocolatey/bin:/cygdrive/c/Program Files/dotnet:/cygdrive/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/cygdrive/c/Program Files (x86)/IncrediBuild:/usr/bin:/cygdrive/c/Program Files/Java/jdk1.8.0_211/bin:/cygdrive/c/Program Files/Perforce:/cygdrive/c/Program Files/Git LFS:/cygdrive/c/ProgramData/nvm:/cygdrive/c/Program Files/nodejs:/cygdrive/c/Program Files/Git/cmd:/cygdrive/c/Windows/system32/config/systemprofile/AppData/Local/Microsoft/WindowsApps:/home/buildbot/.rvm/bin:C:\Android\sdk_30_0_2:/UNITY_PATH/Unity/p4/macos/:/UNITY_PATH/Unity/p4/windows/
    1830: BUILD_CAUSE_MANUALTRIGGER=true
    1831: UNITY_PLAYER_PATH=BUILD_PATH/p/.build/last/default-android/default-android2.apk
    1832: LICENSE_LEGACY_PATH=/cygdrive/c/ProgramData/Unity/
    1833: PREVIOUS_SUCCESSFUL_BUILD_REVISION=f88769eea0633eaf8f6ef5b213abed435da56778
    1834: HOMEDRIVE=C:
    1835: SCM_OAUTH_TOKEN=****
    1836: ChocolateyLastPathUpdate=132857953300109888
    1837: LICENSE_POOL_PATH=/cygdrive/c/BUILD_PATH/AppData/Local/Unity/licenses
    1838: HOMEPATH=\tools\cygwin\home\buildbot
    1839: IRBRC=/home/buildbot/.rvm/rubies/ruby-2.4.2/.irbrc
    1840: UNITY_VERSION=2020_3_18f1
    1842: PARENT_BUILD_GUID=undefined
    1843: JENKINS_SERVER_COOKIE=e3c856913a9f8f25
    1844: VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
     
    bearhugmo, dan_ginovker and dhindman like this.
  6. wrossmck-unity

    wrossmck-unity

    Unity Technologies

    Joined:
    Nov 9, 2021
    Posts:
    106
  7. Rabadash8820

    Rabadash8820

    Joined:
    Aug 20, 2015
    Posts:
    94
    @wrossmck-unity Thanks for that link; those docs have a lot of great info! Why are those docs separate from the actual UCB Manual page though? If you want transparency, seems like the above docs should be combined into the Manual.
     
  8. wrossmck-unity

    wrossmck-unity

    Unity Technologies

    Joined:
    Nov 9, 2021
    Posts:
    106
    100% agree with this, @Rabadash8820.

    We're in the process of consolidating the documentation sources and eventually my plan is to decouple the UCB documentation with the editor manual (similar to how CCD documentation has moved into it's own location) since we support multiple versions of the editor at any given time and make changes independently from the editor release cycle.
     
    Rabadash8820 likes this.