Skip to content

[templates] Fix Merge_Release and Translate_Changelog on shell executors#83

Open
duckhawk wants to merge 1 commit intomainfrom
fix/shell-executor-compat
Open

[templates] Fix Merge_Release and Translate_Changelog on shell executors#83
duckhawk wants to merge 1 commit intomainfrom
fix/shell-executor-compat

Conversation

@duckhawk
Copy link
Copy Markdown
Member

Summary

Both templates/Merge_Release.gitlab-ci.yml and templates/Translate_Changelog.gitlab-ci.yml fail on GitLab runners that use the shell executor because the templates assume root/docker semantics:

  • apt-get install requires root, which shell executors do not have (Permission denied on /var/lib/apt/lists/lock).
  • git config --global writes to the runner user's $HOME (e.g. /opt/gitlab-runner/.gitconfig), which is typically not writable (could not lock config file /opt/gitlab-runner/.gitconfig: Permission denied).

Real log excerpt from a failing merge_and_release job on a shell runner:

$ apt-get update -qq && apt-get install -y -qq git curl jq
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
...
MR merged successfully.
error: could not lock config file /opt/gitlab-runner/.gitconfig: Permission denied
ERROR: Job failed: exit status 1

Note that the image: directive in the templates is silently ignored by shell executors, so the job runs directly on the host as the gitlab-runner user.

Changes

  • Replace the unconditional apt-get install with a command -v presence check. Install only when the tool is actually missing and the job runs as root (typical for docker images). On shell executors the required tools (git, curl, jq, python3) are expected to be preinstalled on the host, and the job now fails fast with a clear message instead of a cryptic apt error.
  • Drop git config --global. Use repo-local git config inside the clone directory (Merge_Release) or git -C "$CI_PROJECT_DIR" config (Translate_Changelog) so nothing is written to $HOME.

The templates continue to work on both docker and shell executors with no runner-side changes beyond having the standard tooling available on the host.

Backport

Cherry-picked to v12.0 in 1c614a3.

Test plan

  • Run merge_and_release job on a shell-executor runner with git, curl, jq preinstalled and confirm it tags and creates a Release without touching $HOME or apt.
  • Run translate_and_create_mr job on a shell-executor runner and confirm the translation MR is created.
  • Run both jobs on a docker runner (e.g. debian:bookworm-slim, python:3.11-slim) and confirm apt-get install still works for any missing tool.
  • Re-run the storage-volume-data-manager MR pipeline that previously failed and confirm the job succeeds.

Both templates failed on GitLab shell-executor runners because:

- `apt-get install` requires root, which shell executors do not have.
- `git config --global` writes to the runner user's $HOME (e.g.
  /opt/gitlab-runner/.gitconfig), which is typically read-only.

Changes:

- Replace unconditional `apt-get install` with a `command -v` presence
  check; install only when tools are actually missing and only when
  running as root (docker images). On shell executors the required
  tools (git, curl, jq, python3) are expected to be preinstalled on
  the host and the job fails fast with a clear message otherwise.
- Drop `git config --global`. Use repo-local `git config` in the
  clone directory (Merge_Release) or `git -C "$CI_PROJECT_DIR" config`
  (Translate_Changelog) so nothing is written to $HOME.

This keeps the templates working on both docker and shell executors
without requiring any runner-side changes beyond having git/curl/jq
(and python3 for Translate_Changelog) available on the host.

Signed-off-by: v.oleynikov <vasily.oleynikov@flant.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant