How do I use PowerShell with Gitlab CI in Gitlab Pages?

Viewed 22313

How do I use PowerShell commands/scripts with Gitlab CI in a .gitlab-ci.yml file which is used to deploy to gitlab pages?

I am trying to execute the build.ps1 file from .gitlab-ci.yml, but when it reaches the build.ps1 line, it gives an error saying /bin/bash: line 5: .build.ps1: command not found

I am trying to use the PowerShell script to convert a file in my repo and have the converted file deployed to gitlab pages using .gitlab-ci.yml

Here is my code:

.gitlab.yml

pages:
  stage: deploy
  script:
  - mkdir .public
  - .\build.ps1
  - cp -r * .public
  - mv .public public
  artifacts:
    paths:
    - public
  only:
  - master
3 Answers

The docker image philippheuer/docker-gitlab-powershell is outdated. The source on Github was also deleted.

I use in my gitlab-ci.yml the following image mcr.microsoft.com/powershell:latest more Informations available here

scriptjob:
  stage: script
  image: 
    name: "mcr.microsoft.com/powershell:latest"
  script:
    - pwsh ./myscript.ps1

For anyone who is having trouble launching grunt within their gitlab CI/CD via a powershell file, add this line to the top of your file:

$env:path += ";" + (Get-Item "Env:AppData").Value + "\npm"
Related