Read more

GitLab CI: debugging failed jobs

Marc Dierig
January 15, 2024Software engineer at makandra GmbH

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.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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
January 15, 2024Software engineer at makandra GmbH
Posted by Marc Dierig to makandra Operations (2024-01-15 17:16)