diff --git a/templates/gitlab-ci-bash.yml b/templates/gitlab-ci-bash.yml index da9ce94e4421a254f373bbf1b08e776e639d6724..8d5aeb14eedf98f8cf68b00b2283de0c8204891e 100644 --- a/templates/gitlab-ci-bash.yml +++ b/templates/gitlab-ci-bash.yml @@ -314,6 +314,28 @@ stages: done } + function maybe_install_packages() { + if command -v apt-get > /dev/null + then + # Debian + if ! dpkg --status "$@" > /dev/null + then + apt-get update + apt-get install --no-install-recommends --yes --quiet "$@" + fi + elif command -v apk > /dev/null + then + # Alpine + if ! apk info --installed "$@" > /dev/null + then + apk add --no-cache "$@" + fi + else + log_error "... didn't find any supported package manager to install $*" + exit 1 + fi + } + function install_bats_libs() { export BATS_LIBRARIES_DIR=/opt/bats/libexec @@ -322,6 +344,13 @@ stages: return fi + if [[ "$https_proxy" || "$HTTPS_PROXY" ]] + then + # BusyBox wget doesn't support proxies and TLS/SSL at the same time: need to use offical full-featured wget instead + + maybe_install_packages wget + fi + # install Bats libraries for lib in $BASH_BATS_LIBRARIES do @@ -333,7 +362,7 @@ stages: target=$(mktemp) # 1: download - log_info " ... download" + log_info " ... download with wget" wget -O "$target" "$lib_url" # 2: unzip @@ -349,9 +378,11 @@ stages: fi done - # debug log - log_info " ... DONE" - ls -lart "$BATS_LIBRARIES_DIR" + if [ -n "${TRACE}" ]; then + # debug log + log_info " ... DONE" + ls -lart "$BATS_LIBRARIES_DIR" + fi } function glob_expand() {