GitLab Runner 15.8.0 cannot checkout branches starting with special characters like hashtags (shell executor)
Summary
I recently added a new GitLab Runner instance (v15.8.0) to my self hosted GitLab instance (v15.8.0). When this runner picks up a job and has to checkout a branch of a repository starting with a hashtag #
(potentially other special characters as well), the runner fails because it cannot find the remote ref, however, an older version of the executable can check out the branch without problems.
Steps to reproduce
The pipeline fails before the first job is even executed, because it fails on checking out the repository.
I am using the git fetch
strategy in my CI-CD settings with a fetch depth of 30. I've tried to see if the git clone
strategy would change anything, but it didn't.
I have added my configuration either way.
.gitlab-ci.yml
stages:
- test
test:
stage: test
script:
- cd web.app.nl
- yarn setup
- yarn precommit-api
- yarn test
- cd Api.App.Nl/web.app.nl
- yarn install --frozen-lockfile
- yarn lint --max-warnings=0
tags:
- latest
Actual behavior
The pipeline fails because it cannot check out the branch with a # in the name. This is the output for the runner on v15.8.0, which fails checking out the branch:
Running with gitlab-runner 15.8.0 (12335144)
on Buildserver 2 Runner 1 [LATEST] RvxG-Lo1, system ID: s_32eec680609d
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on DESKTOP-47BR331...
Getting source from Git repository
00:02
Fetching changes with git depth set to 30...
Reinitialized existing Git repository in C:/GitLab-Runner/builds/RvxG-Lo1/0/bn/MyApp.Nl/.git/
fatal: couldn't find remote ref refs/heads/`#236-Admin-Video-Group-Page
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit status 128
Notice how the branch it's trying to checkout is named:
refs/heads/`#236-Admin-Video-Group-Page
My branch name is #236-Admin-Video-Group-Page
, without the backtick before the branch name.
Running the exact same .gitlab-ci.yml
configuration with the same config.toml
configuration for the runner, with an older runner executable (v15.2.1) on the same instance works without problems. I've added both job logs below.
Expected behavior
The runner is able to checkout the branch normally.
job log v15.8.0
Running with gitlab-runner 15.8.0 (12335144)
on Buildserver 2 Runner 1 [LATEST] RvxG-Lo1, system ID: s_32eec680609d
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on DESKTOP-47BR331...
Getting source from Git repository
00:02
Fetching changes with git depth set to 30...
Reinitialized existing Git repository in C:/GitLab-Runner/builds/RvxG-Lo1/0/bn/MyApp.Nl/.git/
fatal: couldn't find remote ref refs/heads/`#236-Admin-Video-Group-Page
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit status 128
job log v15.2.1
Running with gitlab-runner 15.2.1 (32fc1585)
on Buildserver 2 Runner 1 [LATEST] RvxG-Lo1
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on DESKTOP-47BR331...
Getting source from Git repository
00:05
Fetching changes with git depth set to 30...
Reinitialized existing Git repository in C:/GitLab-Runner/builds/RvxG-Lo1/0/bn/MyApp.Nl/.git/
Checking out c8940f33 as #236-Admin-Video-Group-Page...
...(rest of logs ommitted)...
Environment description
It is a self hosted runner, using the Shell executor with the powershell
(not pwsh
) shell, running on a Windows 10 Pro (OS Build 19045.2486) installation.
config.toml contents
concurrent = 3
check_interval = 0
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "Buildserver 2 Runner 1 [LATEST]"
url = "https://gitlab.mydomain.nl/"
id = 7
token_obtained_at = 2023-01-30T17:10:33Z
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]
Used GitLab Runner version
PS C:\gitlab-runner> ./gitlab-runner --version
Version: 15.8.0
Git revision: 12335144
Git branch: 15-8-stable
GO version: go1.18.9
Built: 2023-01-19T03:19:01+0000
OS/Arch: windows/amd64
Possible fixes
I'm really not sure. I thought this issue might be related however we are on the GitLab version which fixes this problem: gitlab!107994 (merged)
Proposal for solution
{placeholder for a proposed solution to resolve the bug pending analysis.}