Automatically retry N times when clone fails

Description

There are some temporary failures that can happen when cloning a repository to run the build.

This is an example (see link: https://dev.gitlab.org/gitlab/omnibus-gitlab/builds/964408)

Cloning repository...
Cloning into '/builds/gitlab/omnibus-gitlab'...
error: RPC failed; curl 56 SSL read: error:00000000:lib(0):func(0):reason(0), errno 104
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

By automatically retrying we reduce the frustration of not having the one of the builds from a pipeline failing because a temporary issue.

Proposal

We can get the return code from git to see if it was successful or not and automatically retry a few times (with some back-off delay), as chances are if it's a temporary problem, a few seconds of wait time can get you to back to a working state.

Links to related issues and merge requests / references

https://dev.gitlab.org/gitlab/omnibus-gitlab/builds/964408

Assignee Loading
Time tracking Loading