Andreas Vöst
6 months
Andreas Vöst
8 months
Marc Dierig
11 months
Claus-Theodor Riegg
4 years
Andreas Vöst
4 years
Marius Schuller
5 years
Claus-Theodor Riegg
6 years
Claus-Theodor Riegg
7 years
Claus-Theodor Riegg
7 years
Claus-Theodor Riegg
7 years
Claus-Theodor Riegg
8 years

GitLab CI: debugging failed jobs

Posted . Visible to the public. Repeats.

It happens from time to time that a job in a GitLab pipeline fails. Sometimes, however, the error message is too meaningless to be helpful.

Example:

Running with gitlab-runner 16.7.0 (102c81ba)
  on <host>, system ID: <ID>
Resolving secrets
00:00
Preparing the "shell" executor
00:00
Using Shell (bash) executor...
Preparing environment
00:01
Running on <host>...
Getting source from Git repository
00:00
bash: line 157: /bin/mkdir: Argument list too long
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1

For more verbosity your .gitlab-ci.yml can be extended like so:

  • List all variables Show archive.org snapshot
    <job>:
      before_script:
        - export
    

    Note

    You can declare an - export either under before_script:, script:, or after_script:, depending on when your job fails.

  • Enable debug logging Show archive.org snapshot
    <job>:
      variables:
        CI_DEBUG_TRACE: "true"
    

    Warning

    Debug logging can be a serious security risk. The output contains the content of all variables and other secrets available to the job. The output is uploaded to the GitLab server and visible in job logs.

Marc Dierig
Last edit
Marc Dierig
Tags
License
Source code in this card is licensed under the MIT License.