我如何 运行 GitLab 管道中的 PowerShell 脚本?

How can I run a PowerShell script in GitLab pipeline?

我正在 运行 在 Windows VM 上执行管道作业,默认执行程序为 shell。在这项工作中,我希望 运行 一个 powershell 脚本,它位于一个名为 CICD 的目录中,通过以下几行:

- powershell .\CICD\build_script.ps1 x86 $PROJECT_PATH
- .\CICD\build_script.ps1 x86 $PROJECT_PATH
- '.\CICD\build_script.ps1 x86 $PROJECT_PATH'

该脚本有 2 个参数:x86 和 $PROJECT_PATH。 每次我尝试 运行 这些命令之一时,我都会收到此错误:

.\CICD\build_script.ps1 : The term '.\CICD\build_script.ps1' is not recognized as the name of a cmdlet, function, 
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is 
correct and try again.
At line:1 char:1
+ .\CICD\build_script.ps1 x86 C:\GitLab-Runner\builds\BRmNra1o[=12=]\mihnea ...
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (.\CICD\build_script.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

有运行这个脚本的正确方法吗?

你需要 / 而不是 \:

- cd CICD
- ./build_script.ps1 x86 $PROJECT_PATH