Add options to runner configuration to specify commands executed before code clone and build
This is somewhat similar to !20 (closed) but meets a need that I have in my CI setup. I'm running some of my builds on cloud VMs using the new autoscale feature. However, those are across a WAN from my GitLab instance. Some of the repositories that I do builds on are quite large, so the time required to just clone the code adds large overhead to the build process.
I've mitigated this by setting up a caching proxy server on the cloud network using gitpod. This works great, but I need a way to configure those runners to use the proxy Git server instead.
That's where this merge request comes in. I added a new per-runner option that allows the user to inject commands before the Git clone/fetch occurs. This allows me to adjust the Git global configuration to rewrite the fetch URLs that the CI script uses to point to my proxy server instead. This seems to work and seems to be a pretty elegant solution.
I then had to add a second option that allows the specification of commands before the build occurs. This was because my project has submodules in it, which are not currently cloneable by
gitlab-runner. In my
.gitlab-ci.yml, I have some commands to insert an SSH private key from a secure variable into the environment and subsequently clone the code. Since I use the Docker executor, the
git clone occurs in a different container than the subsequent build commands, so my pre-clone commands don't have any effect on the build. Therefore, I added the ability to configure commands run at this point as well.
I know there was some opposition to adding functionality that was like this in !20 (closed), but I really believe this is the best place to add this feature. Any chance of this getting merged?