From 4a44ec82658efd9f31247ad2c4703fa7d3641d74 Mon Sep 17 00:00:00 2001 From: Ben Foster Date: Wed, 29 Oct 2025 13:43:59 -0400 Subject: [PATCH] fix: install python3 if it is not present resolves to-be-continuous/docker#158 Signed-off-by: Ben Foster --- templates/gitlab-ci-docker.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/templates/gitlab-ci-docker.yml b/templates/gitlab-ci-docker.yml index 18e6faa..aa5ec3f 100644 --- a/templates/gitlab-ci-docker.yml +++ b/templates/gitlab-ci-docker.yml @@ -445,6 +445,29 @@ stages: fi } + function maybe_install_python3() { + if ! command -v python3 > /dev/null + then + if command -v apt-get > /dev/null + then + # Debian + apt-get update + apt-get install --no-install-recommends --yes --quiet python3 + elif command -v apk > /dev/null + then + # Alpine + apk add --no-cache python3 + elif command -v dnf > /dev/null + then + # Fedora + dnf install -y -q python3 + else + log_error "... didn't find any supported package manager to install python3" + exit 1 + fi + fi + } + function github_get_latest_version() { if command -v curl &> /dev/null then @@ -837,6 +860,7 @@ stages: function init_workspace() { install_custom_ca_certs maybe_install_awk + maybe_install_python3 unscope_variables eval_all_secrets configure_registries_auth -- GitLab