How to retry an intermittently failing step

Networking issues will stop your job from running but you are able to use a for loop to be able to retry the same command multiple times.

An example command can be found below:

- run: for i in $(seq 1 5); do docker-compose up -d && s=0 && break || s=$? && sleep 10; done; (exit $s)

The for loop will run five times but this could be changed to any number by changing the 5 within the seq 1 5) section of the command.

Replace the `docker-compose up -d` command with the command to are retrying.

The sleep 10 can be changed or removed if required.

It is not recommend to remove the exit $s as this will pass the exit 1 to stop the run on the failing step rather than trying to continue.

If you need any assistance setting the command raise a support ticket with our team and we will be happy to help.

Was this article helpful?
0 out of 0 found this helpful



Article is closed for comments.