Reputation: 2950
I have the following GitLab CI yml file:
stages:
- build
CodeQuality:
stage: build
image:
name: "mcr.microsoft.com/powershell:latest"
script:
- Write-Host "Do your build here, z1234."
The pipelines fails with this error:
/usr/bin/bash: line 105: Write-Host: command not found
In a different SO question, a similiar error message is shown and one comment mentions that the docker container does not have PowerShell installed. Therefore, I added the image
property but it still fails.
I also tried to use
- powershell "Write-Host 'Do your build here, z1234.'"
or this
- powershell -Command "Write-Host 'Do your build here with PAM.'"
but then I only got this error:
$ powershell -Command "Write-Host 'Do your build here with PAM.'"
/usr/bin/bash: line 110: powershell: command not found
but this also did not recognize the command powershell
.
What else am I missing?
Upvotes: 0
Views: 1720
Reputation: 6269
I don't know which shell is configured in your runner but it seems commands in your example are executed in bash
or sh
context.
In the image you use Powershell core pwsh
is available to execute Powershell command.
This script part works :
script:
- pwsh -Command "Write-Host "Do your build here, z1234.""
Upvotes: 1