Job fails immediately after executing pipeline

My self-hosted runner on Windows PowerShell often fails job immediately after executing pipeline. I haven’t tried on the other Windows devices. Saas dockerr runner never fails like this.
I googled, but no similar cases are found… I appreciate any hints.

Problem to solve

The failure log is as below:

Running with gitlab-runner 16.11.1 (535ced5f)
  on test j7r8KZy2z, system ID: s_20182346aa2a
Preparing the "shell" executor
00:00
Using Shell (powershell) executor...
Preparing environment
00:00
Running on _MYUSERNAME...
Getting source from Git repository
00:00
At line:262 char:45
+ $CI_MERGE_REQUEST_DESCRIPTION_IS_TRUNCATED="false"
+                                             ~~~~~~
Unexpected token 'false"
$env:CI_MERGE_REQUEST_DESCRIPTION_IS_TRUNCATED=$CI_MERGE_REQUEST_DESCRIPTION_IS_TRUNCATED
$CI_MERGE_REQUEST_SQUASH_ON_MERGE="false"
$env:CI_MERGE_REQUEST_SQUASH_ON_MERGE=$CI_MERGE_REQUEST_SQUASH_ON_MERGE
$CI_MERGE_REQUEST_SOURCE_PROJECT_ID="57940446"
$env:CI_MERGE_REQUEST_SOURCE_PROJECT_ID=$CI_MERGE_REQUEST_SOURCE_PROJECT_ID
$CI_MERGE_REQUEST_SOURCE_PROJECT_PATH="_MYREPOSITORY"
$env:CI_MERGE_REQUEST_SOURCE_PROJECT_PATH=$CI_MERGE_REQUEST_SOURCE_PROJECT_PATH
$CI_MERGE_REQUEST_SOURCE_PROJECT_URL="https://gitlab.com/_MYREPOSITORY"
$env:CI_MERGE_REQUEST_SOURCE_PROJECT_URL=$CI_MERGE_REQUEST_SOURCE_PROJECT_URL
$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME="feat/mr"
$env:CI_MERGE_REQUEST_SOURCE_BRANCH_NAME=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
$CI_MERGE_REQUEST_SOURCE_BRANCH_PROTECTED="false"
$env:CI_MERGE_REQUEST_SOURCE_BRANCH_PROTECTED=$CI_MERGE_REQUEST_SOURCE_BRANCH_PROTECTED
$CI_OPEN_MERGE_REQUESTS="_MYREPOSITORY!5"
$env:CI_OPEN_MERGE_REQUESTS=$CI_OPEN_MERGE_REQUESTS
$CI_RUNNER_ID="37534344"
$env:CI_RUNNER_ID=$CI_RUNNER_ID
$CI_RUNNER_DESCRIPTION=""
$env:CI_RUNNER_DESCRIPTION=$CI_RUNNER_DESCRIPTION
$CI_RUNNER_TAGS="[`"ue4`"' in expression or statement.
At line:282 char:26
+ $CI_RUNNER_TAGS="[`"ue4`", `"windows`"]"
+                          ~
Missing argument in parameter list.
At line:315 char:7
+ & "git" 'config' '-f' 'C:\GitLab-Runner\builds\j7r8KZy2z\0\_MYREPOSITORY ...
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: ".
At line:1 char:3
+ & {
+   ~
Missing closing '}' in statement block or type definition.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken
 
error: could not lock config file C:\GitLab-Runner\builds\j7r8KZy2z\0\_MYREPOSITORY.tmp\git-template\config: No such file or directory
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 255

I am suspecting that the Gitlab’s system itself is the culprit because the error occurred right after calling the job.
I reregistered some times, but got no effects.

Configuration

  • config.tmol

    concurrent = 1
    check_interval = 0
    connection_max_age = "15m0s"
    shutdown_timeout = 0
    
    [session_server]
      session_timeout = 1800
    
    [[runners]]
      name = "test"
      url = "https://gitlab.com"
      id = 37534344
      token = "*****************************"
      token_obtained_at = 2024-06-02T07:00:10Z
      token_expires_at = 0001-01-01T00:00:00Z
      executor = "shell"
      shell = "powershell"
      [runners.custom_build_dir]
      [runners.cache]
        MaxUploadedArchiveSize = 0
        [runners.cache.s3]
        [runners.cache.gcs]
        [runners.cache.azure]
    
  • .gitlab-ci.yml

    stages:
      - prepare
    
    default:
      tags: [windows,ue4]
      interruptible: true
      before_script:
        - $OutputEncoding.EncodingName
        - chcp 65001
    
    prepare:
      stage: prepare
      tags: [windows,ue4]
      rules:
        - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
          when: always
      script:
        - $OutputEncoding.EncodingName
        - $PSDefaultParameterValues['Out-File:Encoding'] = 'ascii'
        - Write-Output "prepare"
    

Versions

Please select whether options apply, and add the version information.

  • Self-managed
  • GitLab.com SaaS
  • Self-hosted Runners

Versions

  • GitLab (Web: /help or self-managed system information):
    Official SaaS Gitlab

  • GitLab Runner

    PS C:\GitLab-Runner> .\gitlab-runner.exe --version
    Version:      16.11.1
    Git revision: 535ced5f
    Git branch:   16-11-stable
    GO version:   go1.21.9
    Built:        2024-05-03T15:52:47+0000
    OS/Arch:      windows/amd64