Support for local job testing
Description
During the testing, its hard to execute jobs in .gitlab-ci.yaml
on the runner machine from within gitlab-runner context.
Proposal
Improve exec
option so it can run the project from the local directory
Links
https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/1359
Details
Currently exec
option is very cumbersome. It will still clone the repository so your local changes wont be seen and will do that in different directory. There is no easy way to set up local environment variables - $RUNNER_ENV
is pointless so one must resort to changing the yaml file instead of specifying env vars in the current shell.
Current cumbersome solution for me requires:
- Find out the folder where build is located
- Make sure there is no
GIT_STRATEGY: none
in.gitlab-ci.yaml
so that project is built on location.\builds\0\project-0
relative to the project cloned folder. - Run
gitlab-runner exec shell --shell <...> <job_name>
, this will create build. - Set
GIT_STRATEGY: none
to prevent deleting your local changes. - cd to
.\builds\0\project-0
and edit project files there directly. Continue to edit.gitlab-ci.yaml
in original place. - Run 3 again from within project folder (not the build folder).
- If you have any env vars (such as secrets), set them directly in clones dir
.gitlab-ci.yaml
.
You can see that this is cumbersome and error prone. I propose following additions for exec
:
- Option
--localrun
. Just run everything in the local dir without any cloning and moving to other dirs whatsoever. - Look for defined env. vars in the current shell and use them as highest priority. This way the following would work:
$Env:Foo = 'bar'; gitlab-runner exec ...
- Do not delete temporary script that is generated as it can be useful for debugging issues.