Our shared library uses these two (slightly abstraced) calls. The first one works perfectly fine. The second one splits the ${UNITY_PATH}
command into multiple lines split where spaces are.
A workaround is to exclude this command into a one-line-sh command - in case somebody else runs into this issue. But my question remains: Why is the `${UNITY_PATH} line split appart in the second scenario but not the first one? First Scenario (working case):
def call() {
sh """
rm -fr '${WORKSPACE}/${RELATIVE_TARGET_DIR_PRODUCTION}/TheWagaduChronicles.Production/Build/'
${UNITY_PATH} -batchmode -projectPath ./${RELATIVE_TARGET_DIR_PRODUCTION}/TheWagaduChronicles.Production -logfile - -executeMethod TheWagaduChronicles.Build.Editor.BuildMenu.BuildMacOSClient
${UNITY_PATH} -batchmode -projectPath ./${RELATIVE_TARGET_DIR_PRODUCTION}/TheWagaduChronicles.Production -logfile - -executeMethod TheWagaduChronicles.Build.Editor.BuildMenu.BuildWindowsClient
"""
}
Second scenario (failing case):
def call(String buildVersion) {
sh """
cd ${WORKSPACE}/${RELATIVE_TARGET_DIR_PRODUCTION}/.
<more stuff happening>
jq '.Version_ = ${buildVersion}' version.json | sponge version.json
${UNITY_PATH} -batchmode -projectPath ./$RELATIVE_TARGET_DIR_PRODUCTION/GreatProject.Production -logfile - -executeMethod GreatProject.Build.Editor.BuildMenu.SetBuildVersion
git commit -m \"Bumps version to $buildVersion\"
<more stuff happening>
git push --tags --verbose
"""
}
Leads to:
11:40:54 COMMAND LINE ARGUMENTS:
11:40:54 /Applications/Unity/Hub/Editor/2021.3.12f1/Unity.app/Contents/MacOS/Unity
11:40:54 -batchmode
11:40:54 -projectPath
11:40:54 ./production/TheWagaduChronicles.Production
11:40:54 -logfile
11:40:54 -
11:40:54 -executeMethod
11:40:54 TheWagaduChronicles.Build.Editor.BuildMenu.SetBuildVersion
11:40:54 Couldn't set project path to:
11:40:54
11:40:54 Aborting batchmode due to failure:
11:40:54 Couldn't set project path to:
11:40:54
Workaround Hack:
def call(String buildVersion) {
sh """
cd ${WORKSPACE}/${RELATIVE_TARGET_DIR_PRODUCTION}/.
<more stuff happening>
jq '.Version_ = ${buildVersion}' version.json | sponge version.json
"""
sh "${UNITY_PATH} -batchmode -projectPath ./$RELATIVE_TARGET_DIR_PRODUCTION/GreatProject.Production -logfile - -executeMethod GreatProject.Build.Editor.BuildMenu.SetBuildVersion"
sh """
git commit -m \"Bumps version to $buildVersion\"
<more stuff happening>
git push --tags --verbose
"""
}
Researched and troubleshooted until I found the hack included in the question. But I couldn't find an explanation.