Skip to content

Add PowerShell Core to Windows Runner helper image

What does this MR do?

  • Upgrades Powershell Core version to 7.0.3 in Vagrantfile and in the CI image.
  • Installs Powershell Core 7.0.3 on the Windows Docker helper image.
  • Updates the documentation so that it is clear that it is now possible to leverage the nanoserver image.
  • Adds logic to allow the docker-windows executor to use the configured shell on the helper image. Some thoughts about this:
    • I didn't add this logic to the k8s executor since the value is not used.
    • We'll be able to remove this once pwsh will be the only shell supported in Windows helper images (%15.0?).
    • We could call this "temporary" property WindowsShell to make it evident that it only applies to Windows.
  • Ensures that BOM is not issued for Powershell Core (see discussion in #3896 (comment 157830131)).

Why was this MR needed?

So that the pwsh shell is available to the docker-windows executor and built-in scripts leverage it when it is the configured shell for a Runner.

What's the best way to test this MR?

  1. In a host such as your development machine or another computer in the network, set up a local Docker registry, so that the Runner can fetch the Windows Docker image from it, and we sidestep the Windows licensing issues preventing us from pushing to a public repo:

    docker run -p 5000:5000 registry
  2. Configure your local Docker client to allow using the local registry:

    {
      "insecure-registries": [
        "localhost:5000"
      ],
      "allow-nondistributable-artifacts": [
        "localhost:5000"
      ]
    }
  3. Build the Windows Docker image using ci/build_release_windows_images.ps1 (see steps in #27115 (closed))

    $Env:CI_REGISTRY_IMAGE="localhost:5000/gitlab"
    $Env:WINDOWS_VERSION = 'servercore1809'
    $Env:GIT_LFS_256_CHECKSUM= "5c12db9728b53cba23e5f58f4a53d88cb2132e82fa1de0f8a79ce9d112e4d396"
    $Env:GIT_256_CHECKSUM= "bd91db55bd95eaa80687df28877e2df8c8858a0266e9c67331cfddba2735f25c"
    $Env:GIT_VERSION= "2.21.0"
    $Env:GIT_VERSION_BUILD= "1"
    $Env:GIT_LFS_VERSION= "2.7.1"
    $Env:PWSH_VERSION= "7.0.1"
    $Env:PWSH_256_CHECKSUM= "e652a8e0f7d088106ea018d4b9e02373d4331907efa64a60dc32e097b165d8fd"
    $Env:SKIP_CLEANUP=1
    .\ci\build_release_windows_images.ps1
  4. Check that Powershell Core is available on the image (and version matches):

    PS> docker run -ti --rm gitlab/gitlab-runner-helper:x86_64-<git_hash>-servercore1809 pwsh -version
    PowerShell 7.0.3
  5. Tag the image and push it to your local registry:

    docker tag gitlab/gitlab-runner-helper:x86_64-<git_hash>-servercore1809 localhost:5000/gitlab/gitlab-runner-helper:x86_64-<git_hash>-servercore1809
    docker push localhost:5000/gitlab/gitlab-runner-helper:x86_64-<git_hash>-servercore1809
  6. Register a Runner on a Windows machine with the pwsh shell and the helper image we just built:

    .\out\binaries\gitlab-runner-windows-amd64.exe register -n -u https://gitlab.com/ -r <token> --tag-list windows,docker,pwsh --executor docker-windows --shell pwsh --docker-image "mcr.microsoft.com/powershell:latest" --docker-helper-image "localhost:5000/gitlab/gitlab-runner-helper:x86_64-<git_hash>-servercore1809"
  7. Run a job against the runner just registered:

    start_evaluation:
      script:
        - (Get-Host).Version
      tags:
        - windows
        - pwsh

What are the relevant issue numbers?

Closes #13139 (closed)

Merge request reports