Skip to content

Unwanted log messages with shell=Powershell

Summary

With Gitlab-runner 15.6.0 and 15.6.1 for Windows, jobs produce unwanted job logs: #< CLIXML and <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs> at each step.

These logs are not present with Gitlab-runner 15.5.1.

Steps to reproduce

Every job that runs on shell powershell (not pwsh).

Example of jobs :

.gitlab-ci.yml
stages:          
  - test

shell-job:       
  stage: test
  # add tags to run this job with shell runner
  script:
    - Write-Host "hello"

docker-windows-job:
  stage: test
  # add tags to run this job with docker-windows runner
  image: mcr.microsoft.com/windows/servercore:ltsc2019
  script:
    - Write-Host "hello"

Actual behavior

docker-windows-job outputs:
[0KRunning with gitlab-runner 15.6.1 (133d7e76)[0;m
[0K  on Exécuteur Docker Windows DFqX-Uui[0;m
section_start:1669734950:prepare_executor
[0K[0K[36;1mPreparing the "docker-windows" executor[0;m[0;m
[0KUsing Docker executor with image mcr.microsoft.com/windows/servercore:ltsc2019 ...[0;m
[0KPulling docker image mcr.microsoft.com/windows/servercore:ltsc2019 ...[0;m
[0KUsing docker image sha256:4503e186c64d1c87f98c21e90a58566b00431bd8a47cca591ea1802ecd6fb389 for mcr.microsoft.com/windows/servercore:ltsc2019 with digest mcr.microsoft.com/windows/servercore@sha256:cbb8b0a709b4e0868cd2e30b1485358197b1021bb0dd4261e36b3af3ca48fd0b ...[0;m
section_end:1669734950:prepare_executor
[0Ksection_start:1669734950:prepare_script
[0K[0K[36;1mPreparing environment[0;m[0;m
#< CLIXML
Running on RUNNER-DFQX-UUI via 
SRV-GLR-DOCWIN1...
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669734991:prepare_script
[0Ksection_start:1669734991:get_sources
[0K[0K[36;1mGetting source from Git repository[0;m[0;m
#< CLIXML
[32;1m$ git config --global --add safe.directory $CI_PROJECT_DIR.replace('c:','C:').replace('\', '/')[0;m
[32;1mFetching changes with git depth set to 20...[0;m
Initialized empty Git repository in C:/builds/morefa/test-runner-win/.git/
[32;1mCreated fresh repository.[0;m
[32;1mChecking out b3d55ada as main...[0;m
git-lfs/3.2.0 (GitHub; windows amd64; go 1.18.2)

[32;1mSkipping Git submodules setup[0;m
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669735037:get_sources
[0Ksection_start:1669735037:step_script
[0K[0K[36;1mExecuting "step_script" stage of the job script[0;m[0;m
[0KUsing docker image sha256:4503e186c64d1c87f98c21e90a58566b00431bd8a47cca591ea1802ecd6fb389 for mcr.microsoft.com/windows/servercore:ltsc2019 with digest mcr.microsoft.com/windows/servercore@sha256:cbb8b0a709b4e0868cd2e30b1485358197b1021bb0dd4261e36b3af3ca48fd0b ...[0;m
#< CLIXML
[32;1m$ Write-Host "hello"[0;m
hello
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669735077:step_script
[0Ksection_start:1669735077:cleanup_file_variables
[0K[0K[36;1mCleaning up project directory and file based variables[0;m[0;m
#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669735117:cleanup_file_variables
[0K[32;1mJob succeeded[0;m

Problems are the outputs #< CLIXML and <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669735117:cleanup_file_variables

Expected behavior

Same output, without #< CLIXML and <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669735117:cleanup_file_variables

Environment description

The problem is on a personal server, Windows Server 2019, with executor shell or docker-windows. Powershell with version 5.1.17763.2931, Gitlab-runner 15.6.0 ou 15.6.1.

config.toml
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "Shell runner"
  executor = "shell"
  shell = "powershell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

[[runners]]
  name = "Docker-Windows runner"
  executor = "docker-windows"
  pre_clone_script = "git config --global --add safe.directory $CI_PROJECT_DIR.replace('c:','C:').replace('\\', '/')"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.docker]
    tls_verify = false
    image = "mcr.microsoft.com/windows/servercore:2019"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = true
    shm_size = 0

Runner version

Version: 15.6.1

Git revision: 133d7e76

Git branch: 15-6-stable

GO version: go1.18.8

Built: 2022-11-24T15:24:44+0000

OS/Arch: windows/amd64

Possible fixes

This problem is new to version 15.6.0. Using version 15.5.0 or 15.5.1 is a workaround.