Binary `head` in Docker image `release-cli` unexpected exit code

Summary

Using the Docker image registry.gitlab.com/gitlab-org/release-cli as a base for a stage, when the command head is executed within the stage it unexpectedly returns an error exit code, causing the pipeline to fail. Where as the command works perfectly fine on other images, including alpine which I believe is used as a base for registry.gitlab.com/gitlab-org/release-cli.

Steps to reproduce

These steps are specific to what I was trying to accomplish, which was finding the latest tag. This can probably be reproduced in numerous other ways.

  1. Use the Docker image registry.gitlab.com/gitlab-org/release-cli as a base for a stage.
  2. Clone any repository which has tags.
  3. Change into the directory of the cloned repository.
  4. Execute the command git tag --sort=-committerdate | head -1.

Example Project

https://gitlab.com/DeveloperC/zsh-simple-abbreviations/-/jobs/1954598939

What is the current bug behavior?

The command git tag --sort=-committerdate | head -1 exits with a 141 status code.

What is the expected correct behavior?

The command git tag --sort=-committerdate | head -1 exits with a 0 status code.

Relevant logs and/or screenshots

Source https://gitlab.com/DeveloperC/zsh-simple-abbreviations/-/jobs/1954598939

[0KRunning with gitlab-runner 14.6.0~beta.71.gf035ecbf (f035ecbf)[0;m
[0K  on green-2.shared.runners-manager.gitlab.com/default ns46NMmJ[0;m
section_start:1641660818:resolve_secrets
[0K[0K[36;1mResolving secrets[0;m[0;m
section_end:1641660818:resolve_secrets
[0Ksection_start:1641660818:prepare_executor
[0K[0K[36;1mPreparing the "docker+machine" executor[0;m[0;m
[0KUsing Docker executor with image registry.gitlab.com/gitlab-org/release-cli ...[0;m
[0KAuthenticating with credentials from job payload (GitLab Registry)[0;m
[0KPulling docker image registry.gitlab.com/gitlab-org/release-cli ...[0;m
[0KUsing docker image sha256:c2d3a3c3b9ad5ef63478b6a6b757632dd7994d50e603ec69999de6b541e1dca8 for registry.gitlab.com/gitlab-org/release-cli with digest registry.gitlab.com/gitlab-org/release-cli@sha256:68e201226e1e76cb7edd327c89eb2d5d1a1d2b0fd4a6ea5126e24184d9aa4ffc ...[0;m
section_end:1641660826:prepare_executor
[0Ksection_start:1641660826:prepare_script
[0K[0K[36;1mPreparing environment[0;m[0;m
Running on runner-ns46nmmj-project-28523191-concurrent-0 via runner-ns46nmmj-shared-1641660776-109dbccd...
section_end:1641660827:prepare_script
[0Ksection_start:1641660827:get_sources
[0K[0K[36;1mGetting source from Git repository[0;m[0;m
[32;1m$ eval "$CI_PRE_CLONE_SCRIPT"[0;m
[32;1mFetching changes...[0;m
Initialized empty Git repository in /builds/DeveloperC/zsh-simple-abbreviations/.git/
[32;1mCreated fresh repository.[0;m
[32;1mChecking out 0c667e3c as refs/merge-requests/9/head...[0;m

[32;1mSkipping Git submodules setup[0;m
section_end:1641660828:get_sources
[0Ksection_start:1641660828:step_script
[0K[0K[36;1mExecuting "step_script" stage of the job script[0;m[0;m
[0KUsing docker image sha256:c2d3a3c3b9ad5ef63478b6a6b757632dd7994d50e603ec69999de6b541e1dca8 for registry.gitlab.com/gitlab-org/release-cli with digest registry.gitlab.com/gitlab-org/release-cli@sha256:68e201226e1e76cb7edd327c89eb2d5d1a1d2b0fd4a6ea5126e24184d9aa4ffc ...[0;m
[32;1m$ apk add git[0;m
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
(1/7) Installing ca-certificates (20191127-r5)
(2/7) Installing brotli-libs (1.0.9-r3)
(3/7) Installing nghttp2-libs (1.42.0-r1)
(4/7) Installing libcurl (7.79.1-r0)
(5/7) Installing expat (2.2.10-r1)
(6/7) Installing pcre2 (10.36-r0)
(7/7) Installing git (2.30.2-r0)
Executing busybox-1.32.1-r6.trigger
Executing ca-certificates-20191127-r5.trigger
OK: 19 MiB in 21 packages
[32;1m$ CURRENT_VERSION=$(cat src/zsh-simple-abbreviations | grep "^VERSION" | cut -d "'" -f 2)[0;m
[32;1m$ echo "${CURRENT_VERSION}" | grep "^${SEMANTIC_VERSIONING_REGEX}$"[0;m
0.3.0
[32;1m$ git tag --sort=-committerdate[0;m
0.3.0
0.2.0
0.1.0
[32;1m$ git tag --sort=-committerdate | head -1[0;m
0.3.0
section_end:1641660830:step_script
[0Ksection_start:1641660830:cleanup_file_variables
[0K[0K[36;1mCleaning up project directory and file based variables[0;m[0;m
section_end:1641660831:cleanup_file_variables
[0K[31;1mERROR: Job failed: exit code 141
[0;m

Output of checks

This bug happens on GitLab.com.

Possible fixes

No idea.

Edited by Jaime Martinez