【发布时间】:2021-03-20 22:30:16
【问题描述】:
在我的 Unity 项目中实施持续集成时遇到的这个问题让我大吃一惊。
我下载了 Gitlab CI Runner 并将我的台式电脑注册为我项目的特定运行器。我将执行者设置为shell,并且没有为我的跑步者设置任何标签。
然后我编写了一个简单的测试,其中包含一行 Assert.Fail()。如果我进入 Unity > Window > General > Test Runner 并运行我的测试 - 它失败:
然后我在我的项目中添加了gitlab-ci.yml:
stages:
- test
- build
- deploy
unit-test:
script:
- echo testing ; & "C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Unity.exe" -batchmode -projectPath "C:\workspace\automatedtesting\Simple Lane Runner" -runTests -testPlatform editmode -testResults "C:\workspace\automatedtesting\testresults\results.xml" -logFile "C:\workspace\automatedtesting\testresults\logfile.log"
stage: test
如果我在本地运行script 上的线路,我的计算机会有点忙,回显“测试”。如果我然后转到我的logfile.log 或results.xml,我可以看到它们刚刚创建,并且包含说明我的测试失败的信息。
但是,管道作业只是简单地成功了。它不会引发任何错误。
Running with gitlab-runner 13.6.0 (8fa89735)
on Kamiel-Desktop-Runner 69UDXkRe
Resolving secrets
00:00
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on DESKTOP-ONQCMQA...
Getting source from Git repository
00:02
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in C:/GitLab-Runner/builds/69UDXkRe/0/visserk18/automatedtesting/.git/
Checking out 7a897989 as master...
git-lfs/2.10.0 (GitHub; windows amd64; go 1.12.7; git a526ba6b)
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:08
$ echo testing ; & "C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\Unity.exe" -batchmode -projectPath "C:\workspace\automatedtesting\Simple Lane Runner" -runTests -testPlatform editmode -testResults "C:\workspace\automatedtesting\testresults\results.xml" -logFile "C:\workspace\automatedtesting\testresults\logfile.log"
testing
Cleaning up file based variables
00:00
Job succeeded
我在这里遗漏了什么吗?一旦遇到失败的测试,这项工作不应该失败吗..?无论我在哪里看,(例如在本指南中:https://engineering.etermax.com/continuous-integration-in-unity-with-gitlab-ci-cd-part-1-e902c94c0847 或我可以在 github 上找到的其他“示例统一项目”)除了我的 .yml 中的内容之外,我没有看到其他任何事情发生。我在监督什么吗?
【问题讨论】:
-
我认为使用调用符号不一定能捕获输出。你试过没有'echo'或'&'吗?
-
我试过没有
echo,没有回显.yml文件将被标记为无效。如果我也省略了 &,它也会将语法标记为无效。 -
您可以将:
before_script: $env:Path = $env:Path + ";C:\Program Files\Unity\Hub\Editor\2020.1.4f1\Editor\"添加到您的gitlab-ci.yml,然后您应该可以直接调用Unity.exe,无需&或路径。 -
这是一个很好的说明,谢谢。我最终做的是将我的项目和统一编辑器移动到不包含任何空格的目录,完全消除对字符串的需要。但我同意这有点糟糕:)