首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GitLab -写入-主机:未找到命令

GitLab -写入-主机:未找到命令
EN

Stack Overflow用户
提问于 2021-02-24 00:08:27
回答 1查看 280关注 0票数 0

我有以下GitLab CI yml文件:

代码语言:javascript
复制
stages:
  - build
  
CodeQuality:
  stage: build
  image: 
    name: "mcr.microsoft.com/powershell:latest"
  script:
    - Write-Host "Do your build here, z1234."

管道失败,并显示以下错误:

代码语言:javascript
复制
/usr/bin/bash: line 105: Write-Host: command not found

在一个不同的SO问题中,显示了一个类似的错误消息,其中一条评论提到停靠容器没有安装PowerShell。因此,我添加了image属性,但它仍然失败。我还试着用

代码语言:javascript
复制
- powershell "Write-Host 'Do your build here, z1234.'"

或者这个

代码语言:javascript
复制
- powershell -Command "Write-Host 'Do your build here with PAM.'"

但是我只得到了这个错误:

代码语言:javascript
复制
$ powershell -Command "Write-Host 'Do your build here with PAM.'"
/usr/bin/bash: line 110: powershell: command not found

但这也不能识别命令powershell

我还漏掉了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-26 05:32:29

我不知道在您的运行器中配置了哪个shell,但您示例中的命令似乎是在bashsh上下文中执行的。

在映像中,您可以使用Powershell核心pwsh来执行Powershell命令。

此脚本部分工作:

代码语言:javascript
复制
script:
- pwsh -Command "Write-Host "Do your build here, z1234.""
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66336769

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档