Middle
How does GitLab Runner work?
sobes.tech AI
Answer from AI
GitLab Runner is an agent that executes CI/CD tasks. It exchanges data with GitLab CI/CD via API. When an event occurs in GitLab that triggers a pipeline (for example, a commit), GitLab sends a request to the runner. The runner fetches the task, clones the repository, executes the commands described in .gitlab-ci.yml, and sends the result back to GitLab.
Key aspects of operation:
- Runner types: Shared, Specific, Group. They differ in scope and availability for projects.
- Executor: Defines the environment in which tasks are executed. Popular executors include
shell,docker,kubernetes,virtualbox,ssh. The choice of executor affects task isolation and environment. - Registration: The runner registers with GitLab using a token, linking it to a specific instance, group, or project.
- Polling: The runner periodically polls GitLab for new tasks.
config.toml: Configuration file defining runner settings, including executor type, number of parallel jobs, and other parameters.
Example structure of config.toml:
# global settings
concurrent = 4
# runner settings
[[runners]]
name = "my-docker-runner"
url = "https://gitlab.com/"
token = "YOUR_RUNNER_TOKEN"
executor = "docker" # executor choice
[runners.docker]
tls_verify = false
image = "ubuntu:latest" # image when using docker executor
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]