GitLab Runner windows helper image 17.8.1 does not have PowerShell
Summary
The new runner 17.8.1 is giving following error in docker-windows:
Using Docker executor with image docker:27.3.1-windowsservercore ... Pulling docker image docker:27.3.1-windowsservercore ... Using docker image sha256:b97457ae6f523445fb75426553bfe303fced59f9220ae078d7e4c87715d45fc5 for docker:27.3.1-windowsservercore with digest docker@sha256:a9b533ad3897a104820d026bf803f1961f7a5878421714a612247124d0acef64 ... Preparing environment 00:24 'powershell' is not recognized as an internal or external command, operable program or batch file. ERROR: Job failed: prepare environment: exit code 1. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
Steps to reproduce
What do you need to do to reproduce the bug? Please include job definitions or git repository structure if relevant
- On Windows 11 24H2, install gitlab runner 17.8.1 with docker-windows option.
- run any windows image docker job and it will give an error of 'powershell' is not recognized as an internal or external command, during environment preparation.
.gitlab-ci.yml
job_build:
stage: build
image: docker:27.3.1-windowsservercore
variables:
GIT_STRATEGY: clone
before_script:
- |
docker --version
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- |
docker build --pull -t "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}" .
docker push "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}"
tags:
- Windows11Docker
Actual behavior
Not recognizing powershell (seems like helper windows image does not have powershell or at least in the path)
Expected behavior
It should prepare the environment correctly and start executing the job.
Relevant logs and/or screenshots
job log
Running with gitlab-runner 17.8.1 (a1fca00e)
on ApplicsStudio Build Env drdxiLi8y, system ID: s_b087b7b64a7d
Resolving secrets
Preparing the "docker-windows" executor
00:01
Using Docker executor with image docker:27.3.1-windowsservercore ...
Pulling docker image docker:27.3.1-windowsservercore ...
Using docker image sha256:b97457ae6f523445fb75426553bfe303fced59f9220ae078d7e4c87715d45fc5 for docker:27.3.1-windowsservercore with digest docker@sha256:a9b533ad3897a104820d026bf803f1961f7a5878421714a612247124d0acef64 ...
Preparing environment
00:24
'powershell' is not recognized as an internal or external command,
operable program or batch file.
ERROR: Job failed: prepare environment: exit code 1. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
Environment description
- Self hosted Gitlab instance version: GitLab Enterprise Edition 17.9.0-pre feb10ede265
- Gitlab runner version (self hosted): 17.8.1
- Windows 11 24H2
- Docker version 27.4.0 (windows images)
config.toml contents
[[runners]]
name = "ApplicsStudio Build Env"
url = "https://gitlab.mrs-electronic.com"
id = 122
token = "my-token"
token_obtained_at = 2023-09-05T07:32:28Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker-windows"
pre_clone_script = "git config --global --add safe.directory '*'"
pre_get_sources_script = "git config --global --add safe.directory '*'"
shell = "powershell"
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.docker]
tls_verify = false
image = "mcr.microsoft.com/windows/servercore:1809"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["c:\\cache", "//./pipe/docker_engine://./pipe/docker_engine"]
shm_size = 0
Used GitLab Runner version
PS C:\GR\New> .\gitlab-runner-windows-amd64.exe --version
Version: 17.8.1
Git revision: a1fca00e
Git branch: 17-8-stable
GO version: go1.23.2 X:cacheprog
Built: unknown
OS/Arch: windows/amd64
PS C:\GR\New>
Workaround
Override helper_image inside Runner config and use 17.7.1.
You will need to select the correct target windows version (1809, 21H2 etc.)
Example:
[[runners]]
(...)
executor = "docker"
[runners.docker]
(...)
helper_image = "registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-v17.8.1-servercore21H2"
Possible fixes
- Runner base images updates
