Troubleshooting


Error Handling

If a command can fail wrap it in if

Otherwise it will break the job/pipeline

job_name:
  script:
  - |
    if ! command; then
        echo "ERROR: Failed to run command."
        false
    fi

Use command || true is dangerous because it hides errors

(Let’s not talk about readability of bash )


Testing locally

gitlab-runner

Test a single job using Docker using gitlab-runner :

gitlab-runner exec docker <job_name>

Works for more executors: shell, ssh, docker-ssh and more!

This is deprecated and will be removed in GitLab 17.0

gitlab-ci-local

Run whole pipelines locally using gitlab-ci-local

Supports shell and Docker executor