在gitlab ci yaml中用空格封装字符串

Par*_*ram 5 powershell yaml gitlab-ci

如何在 GitLab CI YAML 文件中指定包含空格的字符串文字?

例如,我用来调用位于 gitlab-ci.yml 文件中的 C:\Program Files (x86)...\msbuild.exe 的 msbuild.exe,如下所示

build:
   - C:\Program Files (x86)\...\msbuild.exe MySolution.sln
Run Code Online (Sandbox Code Playgroud)

我尝试使用单引号和双引号来封装路径,但失败了。

有任何想法吗?谢谢

Ref*_*ker 0

这个链接讨论了同样的问题。它已经存在 3 年了,从那时起,GitLab 改变了很多东西,链接中的答案不再相关。他们更改的一件事是,当运行程序设置为shell类型时,现在使用它Windows PowerShell而不是 cmd.exe。因此,这是一个适合我的解决方案的示例:

  1. 准备好一个build.bat文件,其中包含以下内容:

    `"C:\Program Files (x86)\Microsoft Visual 
    Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe" some_solution.sln /m 
    /t:Build /p:Configuration=Release /p:Platform=x64`.
    
    Run Code Online (Sandbox Code Playgroud)

    将其作为您的存储库的一部分提交。

  2. .gitlab-ci.yml文件看起来像这样:

    build_job:
      script: .\build.bat
    
    Run Code Online (Sandbox Code Playgroud)