GitLab CI Pipeline Stage Timeout

TimeoutGitlab Ci

Timeout Problem Overview


I'm using a self-hosted GitLab CI server (community edition v8.9.5) and gitlab-ci-multi-runner 1.2.0 to build a project. One of my pipeline stages (test) takes a while to run and I get the following erm:

> ERROR: Build failed: execution took longer than 3600 seconds

Where do I put the override for this timeout? Can I apply it to just the test pipeline stage?

Timeout Solutions


Solution 1 - Timeout

You can set a global timeout in "Project settings -> CI/CD Pipelines -> Timeout" or "Project settings -> Builds -> Timeout" in older versions.

As of version 12.3, you can set a timeout per stage in your CI .yml file using timeout:

> timeout allows you to configure a timeout for a specific job. For example:

build:
  script: build.sh
  timeout: 3 hours 30 minutes

test:
  script: rspec
  timeout: 3h 30m

> The job-level timeout can exceed the project-level timeout but can’t exceed the Runner-specific timeout.

Solution 2 - Timeout

There are two timeout can be set: project timeout and runner timeout.

Project timeout:

It is possible to set timeout per job from Settings -> CI/CD -> General pipelines

enter image description here

Runner timeout:

runner's timeout can be set from Settings -> CI/CD -> Runners, select the runner from Runners activated for this project and edit the Maximum job timeout from the runner edit form. enter image description here

Be aware that these two types of timeout can be overridden by each other. Refer the docs.

Solution 3 - Timeout

A job-specific timeout was introduced in Gitlab 12.3

https://docs.gitlab.com/ce/ci/yaml/README.html#timeout

build:
  script: build.sh
  timeout: 3 hours 30 minutes

test:
  script: rspec
  timeout: 3h 30m

Solution 4 - Timeout

If running it at Gitlab, then the above stated answers has already told the right way. But if you would like to run the Gitlab CI locally that too with tour own runner, then runners timeout you need to pass with command.

gitlab-runner exec docker job_name --timeout 3600

here it is setting runners timeout as 3600 seconds

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJackpotView Question on Stackoverflow
Solution 1 - TimeouttmtView Answer on Stackoverflow
Solution 2 - TimeoutChuanView Answer on Stackoverflow
Solution 3 - TimeoutPhilLabView Answer on Stackoverflow
Solution 4 - TimeoutshaktisinghmoyalView Answer on Stackoverflow