Unity3d Gitlab CI:根据特定的运行程序设置不同的变量/路径
我正在使用Gitlab CI自动化我的unity构建。为此,我使用了两台机器。(一台Mac和一台windows计算机。重要提示:构建应仅在第一台可用的计算机上运行。) 有问题的行是这样的:脚本:“/Applications/Unity/Hub/Editor/2019.3.14f1/Unity.app/Contents/MacOS/Unity,因为在我的windows runner上,Unity的路径是“S:\Unity\2019.3.14f1\Editor\Unity.exe”\ 尝试使用以下更改修复此问题:Unity3d Gitlab CI:根据特定的运行程序设置不同的变量/路径,unity3d,continuous-integration,gitlab,gitlab-ci,gitlab-ci-runner,Unity3d,Continuous Integration,Gitlab,Gitlab Ci,Gitlab Ci Runner,我正在使用Gitlab CI自动化我的unity构建。为此,我使用了两台机器。(一台Mac和一台windows计算机。重要提示:构建应仅在第一台可用的计算机上运行。) 有问题的行是这样的:脚本:“/Applications/Unity/Hub/Editor/2019.3.14f1/Unity.app/Contents/MacOS/Unity,因为在我的windows runner上,Unity的路径是“S:\Unity\2019.3.14f1\Editor\Unity.exe”\ 尝试使用以下更
windows job:
stage: setpaths
variables:
UNITY_PATH: "S:/Unity/2019.3.14f1/Editor/Unity.exe"
script: "set windows variables..."
tags:
- unity windows runner
#osx job:
# stage: setpaths
# variables:
# UNITY_PATH: "S:/Unity/2019.3.14f1/Editor/Unity.exe"
# script: "set mac variables..."
# tags:
# - unity-mac-runner
问题
除了config.toml解决方案之外:我在Windows上遇到了这个问题(Mac运行时没有问题)
In C:\WINDOWS\TEMP\build_script782418789\script.ps1:185 Zeichen:15
+ ${UNITY_PATH} -batchmode -projectPath ${BUILD_PROJECT_PATH} -runTests ...
+ ~~~~~~~~~~
Unerwartetes Token "-batchmode" in Ausdruck oder Anweisung.
In C:\WINDOWS\TEMP\build_script782418789\script.ps1:185 Zeichen:26
+ ${UNITY_PATH} -batchmode -projectPath ${BUILD_PROJECT_PATH} -runTests ...
+ ~~~~~~~~~~~~
Unerwartetes Token "-projectPath" in Ausdruck oder Anweisung.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
ERROR: Job failed: exit status 1
表达式或语句中的意外标记
这是windows上的my config.toml:
executor = "shell"
shell = "powershell"
environment = [
"UNITY_PATH=S:/Unity/2019.4.1f1/Editor/Unity.exe",
"BUILD_PROJECT_PATH=S:/Gitlab-runner/builds/QZ5_yEjt/0/FussballManager/Game",
"UNITY_BUILD_PATH=S:/Gitlab-runner/builds/QZ5_yEjt/0/FussballManager/Game/WindowsBuild/"
]
一种选择是划分不同的macOS和Windows作业,因此大致如下:
build:mac:
stage: build
script:
- "/Applications/Unity/Hub/Editor/2019.3.14f1/Unity.app/Contents/MacOS/Unity \
-projectPath pathXY \
-executeMethod BuildScript.PerformBuild
-quit"
tags:
- unity-mac-runner
build:windows:
stage: build
script:
- "S:/Unity/2019.3.14f1/Editor/Unity.exe \
-projectPath pathXY \
-executeMethod BuildScript.PerformBuild
-quit"
tags:
- unity-windows-runner
如果脚本非常相似,也可以使用模板/锚定,例如:
.unity_template:
stage: build
script:
- "${UNITY_PATH} -projectPath ${PROJECT_PATH} \
-executeMethod BuildScript.PerformBuild
-quit"
build:mac:
extends: .unity_template
variables:
UNITY_PATH: "/Applications/Unity/Hub/Editor/2019.3.14f1/Unity.app/Contents/MacOS/Unity"
PROJECT_PATH: "pathXY"
tags:
- unity-mac-runner
build:windows:
extends: .unity_template
variables:
UNITY_PATH: "S:/Unity/2019.3.14f1/Editor/Unity.exe"
PROJECT_PATH: "pathXY"
tags:
- unity-windows-runner
这将为管道设置两个作业,并要求两个流道都可用
另一个选项,如您所述,是在跑步者自身上设置路径。我不确定您是如何设置的,但例如:
- mac的
文件:config.toml
windows文件:config.toml
unity_build:
stage: build
script:
- "${UNITY_PATH} \
-projectPath pathXY \
-executeMethod BuildScript.PerformBuild
-quit"
tags:
- unity
有关编辑config.toml
的更多信息,请参阅
这将只为管道设置一个作业,并使用任一可用的unity运行程序(确保两个运行程序都具有unity
标记)
HTH!Thx感谢您的帮助。我首先尝试了您的第二个解决方案:.unity\u模板:但在我的gitlab CI/CD页面上,此提交被标记为卡住。如果单击尚未完成的构建阶段,我可以看到我的mac runner已完成,但我正在等待我的windows runner(目前处于脱机状态)。如果其中一个作业成功,是否有一种方法可以使此生成进入下一阶段?(我不需要同时使用windows runner和mac。)第一个选项(和模板选项)要求两个运行程序都可用。我已更新了更新两个运行程序的config.toml的第三个选项,请告诉我该选项是如何工作的?如果我使用以下选项:标记:-unity mac runner-unity windows runner。我想它也会尝试在两台机器上运行?啊,gitlab会尝试找到一台同时具有两个标记的机器。您可能希望分配这两台机器都有另一个标签,如
unity
。我已再次更新了我的答案。我将在下周末工作(我目前正在休假,无法访问我的windows计算机)。我会将奖励授予你,但我将等待接受此答案。(看起来您的解决方案是正确的,但我们现在缺少一些奇怪的窗口设置;)
[[runners]]
...
environment = ["UNITY_PATH=/Applications/Unity/Hub/Editor/2019.3.14f1/Unity.app/Contents/MacOS/Unity"]
...
[[runners]]
...
environment = ["UNITY_PATH=S:/Unity/2019.3.14f1/Editor/Unity.exe"]
...
unity_build:
stage: build
script:
- "${UNITY_PATH} \
-projectPath pathXY \
-executeMethod BuildScript.PerformBuild
-quit"
tags:
- unity