Search code examples
gitlabgitlab-cigitlab-ci-runner

How can we match gitlab job failure error with retry yaml types?


We have a set of retry types to define for retry.when, e.g. script_failure

But we don’t have anything to match these types with the logs of an arbitrary job OR anything inside the GitLab runner logs, or I don’t see it.

Do we have anything?

An example case is:

  • You get an error in the job
  • You want to retry it because you know it’s a flakiness
  • You find the type in the job logs OR in gitlab runner server side logs
  • You map the type and set it as retry.when

i.e. if I have an arbitrary job failure I want to know to which retry failure type it belongs


Solution

  • The end of the logs should usually say what the job failure reason was. However, some types of failures may mean that logs never make it back to GitLab!

    One reliable way to figure out what the job failure type was is to use the jobs API. These APIs contain the failure_reason key in the response which indicates which failure type (if any) is associated with the job.