我有以下GitLab CI yml文件:
stages:
- build
CodeQuality:
stage: build
image:
name: "mcr.microsoft.com/powershell:latest"
script:
- Write-Host "Do your build here, z1234."管道失败,并显示以下错误:
/usr/bin/bash: line 105: Write-Host: command not found在一个不同的SO问题中,显示了一个类似的错误消息,其中一条评论提到停靠容器没有安装PowerShell。因此,我添加了image属性,但它仍然失败。我还试着用
- powershell "Write-Host 'Do your build here, z1234.'"或者这个
- powershell -Command "Write-Host 'Do your build here with PAM.'"但是我只得到了这个错误:
$ powershell -Command "Write-Host 'Do your build here with PAM.'"
/usr/bin/bash: line 110: powershell: command not found但这也不能识别命令powershell。
我还漏掉了什么?
发布于 2021-02-26 05:32:29
我不知道在您的运行器中配置了哪个shell,但您示例中的命令似乎是在bash或sh上下文中执行的。
在映像中,您可以使用Powershell核心pwsh来执行Powershell命令。
此脚本部分工作:
script:
- pwsh -Command "Write-Host "Do your build here, z1234.""https://stackoverflow.com/questions/66336769
复制相似问题