Skip to content

Job fails on a Powershell Windows runner when run by a user which has a specific range of UTF-8 characters in its name

Summary

Job fails with the error

Unexpected token '��' in expression or statement. At C:\Users\builder\AppData\Local\Temp\build_script741865178\script.ps1:111 cha r:92

  • $GITLAB_USER_NAME="DR CI builder (���?�>�?���?�?���'���>�? �?���?�?���?�� �?� +�?�?�?�� �"�� <<<< DRCIS)"
    • CategoryInfo : ParserError: (��:String) [], ParseException
    • FullyQualifiedErrorId : UnexpectedToken

ERROR: Job failed: exit status 1

if a user name contains specific non-latin characters (even they are in UTF-8) (In the case above user name is "DR CI builder (пользователь сервера сборок ДР DRCIS)" (in Russian)

Steps to reproduce

  1. Setup CI on a Windows Powershell runner.
  2. Change a user name to the name "Г" (without quotes) (least case to reproduce the error; $ printf '\xd0\x93')
  3. Trigger a job by that user (press "Retry" button on a job/push a code, etc).
  4. Job fails with the error similar to
Unexpected token '�?�?��"
$env:GITLAB_USER_NAME=$GITLAB_USER_NAME
$CI_SHARED_ENVIRONMENT="true"
$env:CI_SHARED_ENVIRONMENT=$CI_SHARED_ENVIRONMENT
$CI_RUNNER_VERSION="10.7.2"
$env:CI_RUNNER_VERSION=$CI_RUNNER_VERSION
$CI_RUNNER_REVISION="b5e03c94"
$env:CI_RUNNER_REVISION=$CI_RUNNER_REVISION
$CI_RUNNER_EXECUTABLE_ARCH="windows/amd64"
$env:CI_RUNNER_EXECUTABLE_ARCH=$CI_RUNNER_EXECUTABLE_ARCH
if(Test-Path "d:\Data\Gitlab-CI\builds\9fd8b5ff\0\dr-system\test\testing\.git" 
-PathType Container) {
  echo "n expression or statement.
At C:\Users\builder\AppData\Local\Temp\build_script901570685\script.ps1:122 cha
r:13
+ $GITLAB_USER <<<< _NAME="�"�?�?��"
    + CategoryInfo          : ParserError: (�?�?��"
$env:G...{
  echo "tring) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken
 
ERROR: Job failed: exit status 1

Actual behavior

Powershell script of a job is written containing UTF-8 characters but is not marked with the UTF-8 BOM

Expected behavior

Job is successfully run regardless of a user name.

Relevant logs and/or screenshots

Снимок_экрана_от_2018-07-10_09-00-39

Environment description

GitLab runner on a Windows Server 2008 x64. Shell is Powershell.

Used GitLab Runner version

Version:      10.7.2
Git revision: b5e03c94
Git branch:   
GO version:   go1.8.7
Built:        2018-05-14T11:52:33+00:00
OS/Arch:      windows/amd64

The same issue is observed with a runner built from the latest sources.

P.S. "Г" is the fourth letter of Russian alphabet and the first (in upper case) which leads to the error. "АБВ" does not trigger the issue. "Г", "Д" trigger the issue, but "Е", "Ё", "Ж" (suddenly!) do not!

Edited by Alexey Shumkin