Commit 28ec7fdd authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

fix(bash mode): unmask errors in shell pipelines with 'set -o pipefail'

parent e8dd148b
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ stages:

.docker-scripts: &docker-scripts |
  # BEGSCRIPT
  set -e
  set -eo pipefail

  function log_info() {
      echo -e "[\\e[1;94mINFO\\e[0m] $*"
@@ -474,7 +474,7 @@ stages:
      curl -sSf -I "https://github.com/$1/releases/latest" | awk -F '/' -v RS='\r\n' '/location:/ {print $NF}'
    elif command -v wget &> /dev/null
    then
      wget -q -S -O - "https://github.com/$1/releases/latest" 2>&1 | grep -i "location:" | sed 's|.*/||'
      wget -q -S -O - "https://github.com/$1/releases/latest" 2>&1 | awk -F '/' '/^ *Location:/ {print $NF}'
    elif command -v python3 &> /dev/null
    then
      python3 -c "import urllib.request;url='https://github.com/$1/releases/latest';opener=urllib.request.build_opener(type('NoRedirection', (urllib.request.HTTPErrorProcessor,), {'http_response': lambda self, req, resp: resp, 'https_response': lambda self, req, resp: resp})());req=urllib.request.Request(url, method='HEAD');print(opener.open(req).headers.get('Location').split('/')[-1])"
@@ -669,7 +669,8 @@ stages:
  }

  function eval_all_secrets() {
    encoded_vars=$(env | grep -v '^scoped__' | awk -F '=' '/^[a-zA-Z0-9_]*=@(b64|hex|url)@/ {print $1}')
    # exclude scoped variables and their copies passed to container services (`<service_name>_ENV_scoped__xxx`)
    encoded_vars=$(env | awk -F '=' '$1 !~ /(^|_ENV_)scoped__/ && $2 ~ /^@(b64|hex|url)@/ {print $1}')
    for var in $encoded_vars
    do
      eval_secret "$var"