Make it easier to use the Runner for testing includes
Problem to solve
Our client has loads of commands to configure how it runs on a server. Meanwhile, in order for me to work on developing .gitlab-devops.yml
files I can either commit every 2 seconds or install the gitlab-runner
locally.
This local runner is going to be critical when building complex or custom pipelines. For instance: I am trying to get Ansible Lint & Ansible test results to publish into our quality tabs.
With the runner local, I can execute a particular job via something like gitlab-runner exec docker ansible-lint
. This works great when I am defining everything, but when I'm trying to import other files (or include templates) it is very difficult to determine what I need to run.
EX: I have a .gitlab.yml
which contains:
stages:
- test
- dast
...
include:
- template: Code-Quality.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Jobs/Code-Quality.gitlab-ci.yml
- template: Security/DAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/DAST.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/License-Scanning.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/License-Scanning.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml
And I cannot figure out what to execute. So I look at the run from what I pushed and try that...
➜ gitlab-runner exec docker test
Runtime platform arch=amd64 os=darwin pid=34104 revision=c127439c version=13.0.0
FATAL: no job named "test"
ansible on lint
➜ gitlab-runner exec docker code_quality
Runtime platform arch=amd64 os=darwin pid=34302 revision=c127439c version=13.0.0
FATAL: missing 'script' for job
ansible on lint
➜ gitlab-runner exec docker dast
Runtime platform arch=amd64 os=darwin pid=34522 revision=c127439c version=13.0.0
FATAL: no job named "dast"
It would be extremely helpful if I could run a cmd like you can with mvn
mvn help:describe -Dcmd=compile
...
[INFO] --- maven-help-plugin:3.2.0:describe (default-cli) @ actuator-sample ---
[INFO] 'compile' is a phase corresponding to this plugin:
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
It is a part of the lifecycle for the POM packaging 'jar'. This lifecycle includes the following phases:
...
* process-test-resources: org.apache.maven.plugins:maven-resources-plugin:2.6:testResources
* test-compile: org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile
* package: org.apache.maven.plugins:maven-jar-plugin:2.4:jar
* install: org.apache.maven.plugins:maven-install-plugin:2.4:install
* deploy: org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
...
This week, I spent 1.5 days trying to figure out why my .gitlab-ci.yml
was just failing. I finally got the runner installed locally and started working there and documented how. Once I had it local, I immediately saw my error and fixed it. This error happened before I would have seen anything in GitLab.
Intended users
Anyone who wants to develop/debug beyond vanilla .gitlab-ci.yml
Sasha (Software Developer) Devon (DevOps Engineer) Sidney (Systems Administrator) Simone (Software Engineer in Test) Allison (Application Ops)
User experience goal
Proposal
Modify the existing gitlab-runner
to have a target user of a developer building / debugging the yml locally.
If we do it right, this can also become part of a plugin for IDEs, such as PyCharm or IntelliJ.
Further details
I am trying to test locally rather than commit / wait / commit / wait / commit wait.
With this, I could develop the .gitlab-ci.yml
locally.
Permissions and Security
Documentation
Availability & Testing
What does success look like, and how can we measure that?
As a developer, I can work on my .gitlab-ci.yml
locally and execute it locally (via Docker) and use logs to develop / debug.