Retry installing gems while building gitlab image in pipeline
We periodically fail to install gems from rubygems due to transient network errors. For example:
https://ops.gitlab.net/gitlab-com/database-team/gitlab-com-database-testing/-/jobs/6794362 (internal only):
Installing devise-two-factor 4.0.2
Gem::RemoteFetcher::UnknownHostError: timed out
(https://rubygems.org/gems/listen-3.6.0.gem)
An error occurred while installing listen (3.6.0), and Bundler cannot continue.
Make sure that `gem install listen -v '3.6.0' --source 'https://rubygems.org/'`
succeeds before bundling.
In Gemfile:
guard-rspec was resolved to 4.7.3, which depends on
guard was resolved to 2.16.2, which depends on
listen
Since retrying the job often fixes this, we should add retries in the script.