retry function in before_script after_script stanza
Description
Can be useful to have a retry option even in the before_script and after_script stanza.
This could help to make some jobs more reliable.
In my use case I run a docker login command in the before_script. Whenever it fails the job fail unless I program a retry function manually.
Proposal
I see 2 different opportunities of improvement. The first is to add a retry feature as in the jobs. The second is a way to create a general function that can be re-used across the different jobs. I tried this second approach with the VARIABLE evaluation doing something like this:
variables:
RETRY: "retry() { (for i in 1 2 3 4 5; do \$1 && break || sleep 15;done ; exit 1) }"
stages:
- build
- test
- deploy
before_script:
- 'eval $RETRY'
- retry "docker login ..."
But no way to get the $1 passed properly in the function defined.
Links to related issues and merge requests / references
Please paste a link of the related issues or/and merge requests