79439450

Date: 2025-02-14 13:03:37
Score: 1
Natty:
Report link

So thanks to the answer by @Barmar, and comments by @TobySpeight along with their answer not working on our Gitlab CI pipeline job, running in a docker image, we have to install zsh and create the following script file…

#!/usr/bin/env zsh

set -o pipefail;

counter=0;
while ! { output=$(docker compose --project-directory ./app --env-file ./.env exec php vendor/bin/pest --coverage-clover=clover.xml | tee /dev/fd/3) } 3>&1; do
  counter=$((counter+1));
  if [[ $output != *"done"* ]]; then
    echo "Attempt $counter failed.  Aborting.";
    exit 1;
  fi

  echo "Attempt $counter failed, but with known issue.";
  if [[ $counter -ge 5 ]]; then
    echo "Too many attempts.  Aborting.";
    exit 1;
  fi;
  echo "Re-trying...";
done;

For some reason, using sh or bash gave an "Unexpected token do" syntax error.

Reasons:
  • Blacklisted phrase (0.5): thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Barmar
  • User mentioned (0): @TobySpeight
  • Self-answer (0.5):
Posted by: TobyG