Pipeline support¶
Most of .gitlab-ci.yml is handled by GitLab itself (rules, needs ordering,
retry, parallel, trigger, environments, coverage parsing). This page
lists what a runner has to do, and how TurboCI does it.
Jobs and scripts¶
| Feature | Notes |
|---|---|
before_script, script, after_script |
Each step runs as one shell script with set -e (and pipefail where the shell has it), so a failing command fails the step |
bash / sh |
bash when the image has it, otherwise sh |
when, allow_failure |
after_script sees the job result in CI_JOB_STATUS (success, failed, canceled) |
| Job timeout | From the project or runner setting; the job fails as job execution timeout |
after_script timeout |
5 minutes, or RUNNER_AFTER_SCRIPT_TIMEOUT |
RUNNER_SCRIPT_TIMEOUT |
Caps the script steps inside the job timeout (Go duration: 10m, 1h30m) |
| Cancel from the UI | The script is stopped, after_script still runs, then the job is cleaned up |
hooks:pre_get_sources_script |
Runs before the checkout, after the runner's pre_get_sources_script |
CI_DEBUG_TRACE: "true" |
Every command is echoed (set -x); masking still applies |
| Collapsible log sections | gitlab-runner's: prepare_executor, get_sources, restore_cache, download_artifacts, step_*, after_script, archive_cache (archive_cache_on_failure), upload_artifacts_on_success (_on_failure), cleanup_file_variables; and prepare_containers (Docker: the services and job container started while sources were checked out and the cache and artifacts restored). As in gitlab-runner the cache is saved before artifacts are uploaded |
Images and services (docker executor)¶
| Feature | Notes |
|---|---|
image:name, entrypoint |
The job image needs no git: sources are checked out by a helper container |
image:pull_policy |
Honoured when listed in allowed_pull_policies (others in the list are dropped). Several policies are tried in order, like gitlab-runner: [always, if-not-present] uses the local image when the pull fails; the log says which policy applied. Also for services:pull_policy |
image:docker:platform |
Pulls and runs the image for that platform (e.g. linux/arm64); a local image of another platform counts as missing. Also services:docker:platform |
image:docker:user |
The job container, and so every script, runs as that user (name or UID, optionally :group); the image's own user otherwise. The user needs write access to the project directory to change files there. Also services:docker:user |
services |
Own network per job; reachable by name-derived aliases and alias; variables, command, entrypoint per service. Services are created and started at the same time, and the job container next to them. The script starts once service ports accept connections (up to wait_for_services_timeout, 30 s by default; -1 does not wait), checked from the runner's host when it reaches the job network (Linux with a local dockerd), otherwise from a short-lived helper container on that network |
| Private images | DOCKER_AUTH_CONFIG, the runner's Docker config.json, or GitLab's registry credentials; see private registries |
| Runner services | Services from the runner config start for every job, e.g. Docker-in-Docker; see services for every job |
Sources¶
| Variable | Notes |
|---|---|
GIT_STRATEGY |
fetch updates the checkout an earlier job of the project left in the workspace (see workspaces), clone always clones, none leaves the workspace as it is, empty empties the project directory. Default: the project's Git strategy setting |
GIT_CLEAN_FLAGS |
git clean flags after a fetch into an existing checkout; default -ffdx, none skips it |
GIT_DEPTH |
Shallow fetch depth; the project setting is the default |
GIT_CHECKOUT |
false fetches without checking out |
GIT_FETCH_EXTRA_FLAGS |
Extra git fetch flags, e.g. --filter=blob:none |
GIT_CLONE_PATH |
Checks out into $CI_BUILDS_DIR/<path> (e.g. $CI_BUILDS_DIR/$CI_PROJECT_PATH); a path outside the builds directory fails the job |
GIT_SUBMODULE_STRATEGY |
none, normal, recursive |
GIT_SUBMODULE_DEPTH, GIT_SUBMODULE_PATHS, GIT_SUBMODULE_UPDATE_FLAGS |
As in gitlab-runner |
| Git LFS | LFS objects are pulled after checkout when git-lfs is available; GIT_LFS_SKIP_SMUDGE=1 skips them |
GET_SOURCES_ATTEMPTS |
Retries of the checkout (1–10) |
The pipeline's exact commit is checked out through the refspecs GitLab sends, so merge request and tag pipelines get the right code.
On the docker executor the checkout belongs to the runner's user while the job
usually runs as root, so the runner tells git in the job container to trust it
(safe.directory=*, through GIT_CONFIG_COUNT, after any GIT_CONFIG_*
entries the job sets). git commands in the script work without a
git config --global --add safe.directory line.
Artifacts¶
| Feature | Notes |
|---|---|
paths, exclude, untracked |
Globs with **; paths may use variables |
name, expire_in, when |
when: on_success (default), on_failure, always |
reports |
Uploaded in the format GitLab asks for (zip, gzip, raw) |
| Dependencies | needs and dependencies artifacts are downloaded and extracted before the script: up to 4 archives download at the same time, and they are extracted one by one in the jobs' order, so a later job's files replace an earlier one's as with gitlab-runner |
ARTIFACT_DOWNLOAD_ATTEMPTS |
Retries of dependency downloads (1–10) |
ARTIFACT_COMPRESSION_LEVEL |
fastest (store), fast, default, slow, slowest: deflate level 1, 6, 7, 9 of ZIP artifacts. gitlab-runner honours it only with FF_USE_FASTZIP; TurboCI always does |
Archives are streamed to and from disk, never held in memory. Extraction
rejects entries that would escape the workspace (../, absolute paths,
symlinks pointing outside).
An artifact ZIP is uploaded while it is written, as gitlab-runner does, and
staged in a file next to the workspace at the same time. A failed upload is
sent again from that file: 3 attempts in all (6 while GitLab answers 503),
1 s then 2 s apart (up to 5 s), or after the Retry-After GitLab sends
(at most 60 s). Timeouts (408), rate limits (429) and server errors are
retried; other client errors (403, 413, ...) fail at once. Each retry is
noted in the job log. Files whose start does not compress (random,
encrypted or packed data) and files with the extension of a compressed
format (.png, .gz, .zip, .jar, ...) are stored rather than deflated.
Cache¶
| Feature | Notes |
|---|---|
key |
May use variables; key:files is computed by GitLab |
paths, untracked |
|
policy |
pull-push (default), pull, push |
when |
on_success (default), on_failure, always |
fallback_keys, CACHE_FALLBACK_KEY |
Tried in order when the key has no archive |
RESTORE_CACHE_ATTEMPTS |
Retries of a cache restore (1–10) |
Variables¶
All CI/CD variables GitLab sends, including file-type variables (written to a
file whose path is the variable's value) and $VAR / ${VAR} expansion.
Expansion works as in gitlab-runner. GitLab itself expands variables used in
other variables (A: $B, B: $C) before it sends the job; the runner then
expands once more, for the variables it defines ($CI_BUILDS_DIR,
$CI_PROJECT_DIR, ...) and file variables, which give the path of their file
(KUBECONFIG: $KUBE_FILE points to the file, never its content). Variables
marked Expand variable reference off (raw) are not expanded. Like
gitlab-runner, $1–$9, $*, $@, $#, $?, $! and $- expand to
nothing, so write $$1 in a variable meant for awk '{print $1}';
${NAME:-default} is not a shell default and expands to nothing.
Masked variables, the job token and dependency tokens are replaced by
[MASKED] in the job log, also when a value is split across output chunks.
TurboCI adds the variables gitlab-runner adds:
| Variable | Value |
|---|---|
CI_SERVER |
yes |
CI_BUILDS_DIR, CI_PROJECT_DIR |
/builds, /builds/project in containers |
CI_JOB_IMAGE |
The job image |
CI_JOB_TIMEOUT |
Job timeout in seconds |
CI_JOB_STATUS |
In after_script: success, failed or canceled |
CI_CONCURRENT_ID, CI_CONCURRENT_PROJECT_ID |
Slot of the job on this runner / among the project's jobs |
CI_DISPOSABLE_ENVIRONMENT, CI_SHARED_ENVIRONMENT |
Docker / shell executor |
CI_RUNNER_VERSION, CI_RUNNER_REVISION, CI_RUNNER_EXECUTABLE_ARCH, CI_RUNNER_SHORT_TOKEN |
Runner details |
CI_SERVER_TLS_CA_FILE, GIT_SSL_CAINFO |
When tls_ca_file is set |
Not supported¶
- Executors other than
dockerandshell(Kubernetes, docker-autoscaler, SSH, custom, ...) - Windows jobs and PowerShell
- Native GCS and Azure caches (GCS works through its S3 interoperability with HMAC keys, see S3 cache)
- Interactive web terminal and the session server
- External secrets (
secrets:with Vault, Azure Key Vault, ...) GIT_SUBMODULE_FORCE_HTTPS- Feature flags (
FF_*)
The runner tells GitLab which features it has, so jobs that need an unsupported executor feature are not sent to it.