Skip to content

encoding problem with gitlab-runner on Windows after update to Gitlab CE 11.6.3

Summary

We used Gitlab CE 9.5.4 and a GitlabRunner on a Windows 10 Machine. After a update to Gitlab CE 11.6.3 all Jobs of commits with ä, ö or ü in the commit messages failed (also retries of old commits which worked with Gitlab CE 9.5.4) due to some encoding errors.

This problem also occures when environment variables get set in the script-section of a job to a value which contains ä, ö or ü. For this case a workaround is to change the codepage to 1252. But this is not possible when a environment variable comming from Gitlab contains a ä, ö or ü.

Steps to reproduce

with the following gitlab-ci.yml it can be reproduced:

fails:
  tags: [python36]
  script:
    - set AE=ä
    - python -c "import os;assert os.environ['AE'] == 'ä'"
ok:
  tags: [python36]
  script:
    - chcp 1252
    - set AE=ä
    - python -c "import os;assert os.environ['AE'] == 'ä'"

Example Project

There are no Windows shared runners, so I cannot create a example project.

What is the current bug behavior?

environment variable AE in job fails gets set to õ not to ä

What is the expected correct behavior?

environment variable AE in job should be set to ä in both jobs.

Possible fixes

The problem is that Gitlab encodes everything in cp1252? but the default codepage of command shells on Windoes is 850. A workaround is to the the following registry key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\AutoRun to chcp 1252 > nul. This sets the codepage for all created command shells to 1252 and then it works. But this influences the whole system not only the gitlab-runner.

A solution would be to set the correct codepage in the generated-windows-batch.cmd.

Edited by Stefan Hölzl