Skip to content

gitlab-runner doesn't work with pwsh on windows

Summary

the CI throw on prepare step

image

Steps to reproduce

register a gitlab runner on windows server 2016 with OS lang and region set to zh-hans and China (it should also be any windows OS that not in english language)

run a simple CI like echo 123

Actual behavior

it throw in prepare step (prepare the environment variables)

Expected behavior

no error

Relevant logs and/or screenshots

job log
Running with gitlab-runner 15.4.0 (43b2dc3d)
  on vm-runner q4-3_Dtj
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
Running on WIN-MVPC1TVJ5NV...
Getting source from Git repository
ParserError: 
Line |
 223 |  $password="[MASKED]"
     |             ~~~~~~~~~
     | Unexpected token '[MASKED]" $env:password=$password $username="administrator" $env:username=$username
     | $CI_SHARED_ENVIRONMENT="true" $env:CI_SHARED_ENVIRONMENT=$CI_SHARED_ENVIRONMENT $CI_RUNNER_VERSION="15.4.0"
     | $env:CI_RUNNER_VERSION=$CI_RUNNER_VERSION $CI_RUNNER_REVISION="43b2dc3d"
     | $env:CI_RUNNER_REVISION=$CI_RUNNER_REVISION $CI_RUNNER_EXECUTABLE_ARCH="windows/amd64"
     | $env:CI_RUNNER_EXECUTABLE_ARCH=$CI_RUNNER_EXECUTABLE_ARCH $GIT_LFS_SKIP_SMUDGE="1"
     | $env:GIT_LFS_SKIP_SMUDGE=$GIT_LFS_SKIP_SMUDGE echo "n expression or statement.
Reinitialized existing Git repository in C:/GitLab-Runner/builds/q4-3_Dtj/0/960/mat-spd/.git/
Checking out 7fec0741 as master...
git-lfs/3.2.0 (GitHub; windows amd64; go 1.18.2)

Environment description

config.toml contents
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "vm-runner"
  url = "https://xxxxxxxxxxxxxxxxxxx"
  token = "xxxxxxxxxxxxxxxxxxxxxxx"
  tls-ca-file = "xxxxxxxxxxxxxxxx.pem"
  executor = "shell"
  shell = "pwsh"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

Used GitLab Runner version

Possible fixes

Edited by john