TestDockerCommand_Pwsh fails when new version of PowerShell is out
Overview
As we can see in https://gitlab.com/hirokiyoshida837/gitlab-runner/-/jobs/1025765632#L2066 the TestDockerCommand_Pwsh
is failing with the following trace:
test.go:19: Running with gitlab-runner 13.10.0~beta.169.g8c8d8c3d (8c8d8c3d)
on 4bf5638c
Preparing the "docker" executor
Using Docker executor with image mcr.microsoft.com/powershell:alpine-3.12 ...
Pulling docker image mcr.microsoft.com/powershell:alpine-3.12 ...
Using docker image sha256:f0c345d565ba87eac612cead629e1854e43caca145c92e823ab1feff7653988d for mcr.microsoft.com/powershell:alpine-3.12 with digest mcr.microsoft.com/powershell@sha256:08e7e927bf8647c960401c44107ad120b54da74e1eb60a709bf9f38f5d5bf925 ...
Preparing environment
Running on runner-4bf5638c-project-0-concurrent-0 via
runner-ih9xd9p3-project-24357168-concurrent-0...
Getting source from Git repository
Fetching changes...
Initialized empty Git repository in /builds/gitlab-org/ci-cd/tests/gitlab-test/.git/
Created fresh repository.
Checking out 91956efe as master...
git-lfs/2.11.0 (GitHub; linux amd64; go 1.13.11; git fceccfb7bd)
Skipping Git submodules setup
Executing "step_script" stage of the job script
Using docker image sha256:f0c345d565ba87eac612cead629e1854e43caca145c92e823ab1feff7653988d for mcr.microsoft.com/powershell:alpine-3.12 with digest mcr.microsoft.com/powershell@sha256:08e7e927bf8647c960401c44107ad120b54da74e1eb60a709bf9f38f5d5bf925 ...
$ Write-Output $PSVersionTable
Name Value
---- -----
PSVersion 7.1.2
PSEdition Core
GitCommitId 7.1.2
OS Linux 4.19.78-coreos #1 SMP Mon Oct 14 22:56:39…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Job succeeded
docker_command_test.go:1238:
Error Trace: docker_command_test.go:1238
Error: "\x1b[0KRunning with gitlab-runner 13.10.0~beta.169.g8c8d8c3d (8c8d8c3d)\n\x1b[0;m\x1b[0K on 4bf5638c\n\x1b[0;m\x1b[0K\x1b[36;1mPreparing the \"docker\" executor\x1b[0;m\n\x1b[0;m\x1b[0KUsing Docker executor with image mcr.microsoft.com/powershell:alpine-3.12 ...\n\x1b[0;m\x1b[0KPulling docker image mcr.microsoft.com/powershell:alpine-3.12 ...\n\x1b[0;m\x1b[0KUsing docker image sha256:f0c345d565ba87eac612cead629e1854e43caca145c92e823ab1feff7653988d for mcr.microsoft.com/powershell:alpine-3.12 with digest mcr.microsoft.com/powershell@sha256:08e7e927bf8647c960401c44107ad120b54da74e1eb60a709bf9f38f5d5bf925 ...\n\x1b[0;m\x1b[0K\x1b[36;1mPreparing environment\x1b[0;m\n\x1b[0;mRunning on runner-4bf5638c-project-0-concurrent-0 via \nrunner-ih9xd9p3-project-24357168-concurrent-0...\n\x1b[0K\x1b[36;1mGetting source from Git repository\x1b[0;m\n\x1b[0;m\x1b[32;1mFetching changes...\x1b[0;m\nInitialized empty Git repository in /builds/gitlab-org/ci-cd/tests/gitlab-test/.git/\n\x1b[32;1mCreated fresh repository.\x1b[0;m\n\x1b[32;1mChecking out 91956efe as master...\x1b[0;m\ngit-lfs/2.11.0 (GitHub; linux amd64; go 1.13.11; git fceccfb7bd)\n\n\x1b[32;1mSkipping Git submodules setup\x1b[0;m\n\x1b[0K\x1b[36;1mExecuting \"step_script\" stage of the job script\x1b[0;m\n\x1b[0;m\x1b[0KUsing docker image sha256:f0c345d565ba87eac612cead629e1854e43caca145c92e823ab1feff7653988d for mcr.microsoft.com/powershell:alpine-3.12 with digest mcr.microsoft.com/powershell@sha256:08e7e927bf8647c960401c44107ad120b54da74e1eb60a709bf9f38f5d5bf925 ...\n\x1b[0;m\x1b[32;1m$ Write-Output $PSVersionTable\x1b[0;m\n\nName Value\n---- -----\nPSVersion 7.1.2\nPSEdition Core\nGitCommitId 7.1.2\nOS Linux 4.19.78-coreos #1 SMP Mon Oct 14 22:56:39…\nPlatform Unix\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\nPSRemotingProtocolVersion 2.3\nSerializationVersion 1.1.0.1\nWSManStackVersion 3.0\n\n\x1b[32;1mJob succeeded\n\x1b[0;m" does not contain "PSVersion 7.1.1"
Notice does not contain "PSVersion 7.1.1"
because we are pulling a 7.1.2
image.
Proposal
Version pin the image