Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unity3d Gitlab CI:根据特定的运行程序设置不同的变量/路径_Unity3d_Continuous Integration_Gitlab_Gitlab Ci_Gitlab Ci Runner - Fatal编程技术网

Unity3d Gitlab CI:根据特定的运行程序设置不同的变量/路径

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”\ 尝试使用以下更

我正在使用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
问题

  • 我该怎么做?我该用什么
  • 我试图根据build runner设置unity安装的路径,但无法实现
  • 举个例子就好了。Thx很多;)


    除了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
      文件:
    • config.toml
      windows文件:
    然后在CI文件中,它应该类似于选项1,具有:

    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