Answers: <p>There are three types of timeouts in <code>Gitlab CI</code>:</p>
  
  <ul>
  <li><code>Project</code> timeout</li>
  <li><code>Runner</code> timeout</li>
  <li><code>Jobs</code> timeout</li>
  </ul>
  
  <h2>Project <code>timeout</code></h2>
  
  <p>According to <a href="https://docs.gitlab.com/ee/ci/pipelines/settings.html#timeout" rel="nofollow noreferrer">GitLab docs</a>:</p>
  
  <blockquote>
    <p>Timeout defines the maximum amount of time in minutes that a job is able run. This is configurable under your project’s <strong>Settings &gt; CI/CD &gt; General pipelines settings</strong>. The default value is 60 minutes. Decrease the time limit if you want to impose a hard limit on your jobs’ running time or increase it otherwise. In any case, if the job surpasses the threshold, it is marked as failed</p>
  </blockquote>
  
  <h2>Runner <code>timeout</code></h2>
  
  <p>According to <a href="https://docs.gitlab.com/ee/ci/runners/#setting-maximum-job-timeout-for-a-runner" rel="nofollow noreferrer">GitLab docs</a>:</p>
  
  <blockquote>
    <p>For each <code>Runner</code> you can specify a <em>maximum job timeout</em>.</p>
  </blockquote>
  
  <p><code>Runner</code> timeout settings are defined in runner's edit page</p>
  
  <h2><code>Jobs</code> timeout</h2>
  
  <p><a href="https://docs.gitlab.com/ce/ci/yaml/README.html#timeout" rel="nofollow noreferrer">GitLab CI/CD Pipeline Configuration Reference | GitLab</a></p>
  
  <p><code>Job</code>'s <code>timeout</code> allows you to configure a timeout for a specific job. For example:</p>
  
  <pre><code>build:
    script: build.sh
    timeout: 3 hours 30 minutes
  
  test:
    script: rspec
    timeout: 3h 30m
  </code></pre>
  
  <h1>Precedence of different types of timeout</h1>
  
  <p>The <code>job</code>-level <code>timeout</code> can exceed the <a href="https://docs.gitlab.com/ce/ci/pipelines/settings.html#timeout" rel="nofollow noreferrer"><code>project</code>-level timeout</a> but can not exceed the Runner-specific timeout.</p>
  
  <p>If <code>runner</code> timeout smaller than <a href="https://docs.gitlab.com/ee/ci/pipelines/settings.html#timeout" rel="nofollow noreferrer"><code>project</code> defined timeout</a>, will take the precedence.</p>
  
  <h2>Examples of precedence of <code>timeout</code> directive</h2>
  
  <p>See <a href="https://docs.gitlab.com/ee/ci/runners/#setting-maximum-job-timeout-for-a-runner" rel="nofollow noreferrer">Configuring GitLab Runners | GitLab</a></p>
  
  <pre class="lang-yaml prettyprint-override"><code>name: **Example 1 - Runner timeout bigger than project timeout**
    project_timeout: 2h
    runner_timeout: 24h
    job_timeout: 4h
    resulting_timeout: 4h
  
  name: **Example 2 - Runner timeout not configured**
    project_timeout: 2h
    job_timeout: 4h
    resulting_timeout: 4h
  
  name: **Example 3 - Runner AND job timeout are not configured**
    project_timeout: 24h
    resulting_timeout: 24h
  
  name: **Example 4 - Runner timeout smaller than project timeout**
    project_timeout: 2h
    runner_timeout: 30m
    resulting_timeout: 30m
  
  name: **Example 5 - Runner timeout smaller than Project timeout, Job timeout is bigger than Runner timeout**
    project_timeout: 2h
    runner_timeout: 30m
    job_timeout: 1h
    resulting_timeout: 30m
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2020-03-24T18:07:56.727Z
Answers: thanks for your reply, but as far as I understand these are all runtime timeout, limiting the time a job can effectively run after it is started. But my problem, as I tried to explain in my original post, is that my jobs die because they are not started due to unavailable runners, since my only runner runs one job at each time and the others are killed while waiting to be run. Maybe your reply effectively provides a solution for this case but I misunderstood it?
Answers: Nicola Mori
Answers: CC BY-SA 4.0
Answers: 2020-03-24T18:28:18.050Z
Answers: Hi, @nicola-mori. Just set `Project timeout` to value more than 3h. And leave `Runner timeout` value empty. See `Example 3`
Answers: Yasen
Answers: CC BY-SA 4.0
Answers: 2020-03-24T18:57:39.017Z
Answers: Hi, my Project timeout (i.e. that configured in Settings -> CI / CD Settings -> General pipelines -> Timeout) is currently 2d, and my runner does not have a timeout. Does this correspond to what you are suggesting? Or do  have to put the settings you are suggesting somewhere (I guess in .gitlab-ci.yml)? Sorry for the noob questions but I'm a beginner...
Answers: Nicola Mori
Answers: CC BY-SA 4.0
Answers: 2020-03-25T05:52:57.330Z
Answers: Hi. Please show your `.gitlab-ci.yml`
Answers: Yasen
Answers: CC BY-SA 4.0
Answers: 2020-03-25T09:11:13.177Z
Answers: You can find it here:
  https://basket.fi.infn.it:443/f/0de7f11b48/?dl=1
Answers: Nicola Mori
Answers: CC BY-SA 4.0
Answers: 2020-03-25T13:43:55.533Z
Answers: Sorry, nothing to say
Answers: Yasen
Answers: CC BY-SA 4.0
Answers: 2020-03-24T09:04:00.313Z
Answers: 2020-04-03T19:37:13.553Z
Answers: 2020-04-03T19:37:13.553Z
Answers: Yasen
Body: <p>My pipeline consists of very long jobs that build docker images by compiling a set of packages; all of them require ~ 3 hours on my runner. </p>
  
  <p>I set up my CI so that only one job can run at a time, in order to reduce the disk I/O overhead. But in this way many jobs fail, supposedly because they hit a job start timeout which seems to be bout 1h, with this message:</p>
  
  <blockquote>
    <p>There has been a timeout failure or the job got stuck. Check your timeout limits or try again</p>
  </blockquote>
  
  <p>I have not been able to find how to increase the job start timeout, since all the documentation I found is relative to the job duration timeout. </p>
  
  <p>So I’d need help with this, thanks. I'm using <code>GitLab CE 12.8.1</code> and <code>Gitlab Runner 11.5.1</code>.</p>
  
Comments: CC BY-SA 4.0
Comments: 2024-03-09T12:08:39.983Z
Comments: I know what you are talking about. We can paraphrase it using gitlab specific terminology. You want to specify timeout that controls conversion between pending and started job. For now it seems impossible in gitlab.
Comments: puchu
Tags: <gitlab><gitlab-ci-runner>
Title: Set job start timeout in Gitlab CI
UserDisplayName: Nicola Mori
ThreadText: # Set job start timeout in Gitlab CI
  
  (Asked by: username_0 on 2020-03-23)
  
  My pipeline consists of very long jobs that build docker images by compiling a set of packages; all of them require ~ 3 hours on my runner.
  
  I set up my CI so that only one job can run at a time, in order to reduce the disk I/O overhead. But in this way many jobs fail, supposedly because they hit a job start timeout which seems to be bout 1h, with this message:
  
  > There has been a timeout failure or the job got stuck. Check your timeout limits or try again
  
  I have not been able to find how to increase the job start timeout, since all the documentation I found is relative to the job duration timeout.
  
  So I’d need help with this, thanks. I'm using `GitLab CE 12.8.1` and `Gitlab Runner 11.5.1`.
  
  **Tags:** gitlab, gitlab-ci-runner
  
  > **Comments:**
  > **username_1**: I know what you are talking about. We can paraphrase it using gitlab specific terminology. You want to specify timeout that controls conversion between pending and started job. For now it seems impossible in gitlab.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-03-24. Score: 5
  
  There are three types of timeouts in `Gitlab CI`:
  
  * `Project` timeout
  * `Runner` timeout
  * `Jobs` timeout
  
  ## Project `timeout`
  
  According to [GitLab docs](https://docs.gitlab.com/ee/ci/pipelines/settings.html#timeout):
  
  > Timeout defines the maximum amount of time in minutes that a job is able run. This is configurable under your project’s **Settings > CI/CD > General pipelines settings**. The default value is 60 minutes. Decrease the time limit if you want to impose a hard limit on your jobs’ running time or increase it otherwise. In any case, if the job surpasses the threshold, it is marked as failed
  
  ## Runner `timeout`
  
  According to [GitLab docs](https://docs.gitlab.com/ee/ci/runners/#setting-maximum-job-timeout-for-a-runner):
  
  > For each `Runner` you can specify a *maximum job timeout*.
  
  `Runner` timeout settings are defined in runner's edit page
  
  ## `Jobs` timeout
  
  [GitLab CI/CD Pipeline Configuration Reference | GitLab](https://docs.gitlab.com/ce/ci/yaml/README.html#timeout)
  
  `Job`'s `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
  
  ```
  
  # Precedence of different types of timeout
  
  The `job`-level `timeout` can exceed the [`project`-level timeout](https://docs.gitlab.com/ce/ci/pipelines/settings.html#timeout) but can not exceed the Runner-specific timeout.
  
  If `runner` timeout smaller than [`project` defined timeout](https://docs.gitlab.com/ee/ci/pipelines/settings.html#timeout), will take the precedence.
  
  ## Examples of precedence of `timeout` directive
  
  See [Configuring GitLab Runners | GitLab](https://docs.gitlab.com/ee/ci/runners/#setting-maximum-job-timeout-for-a-runner)
  
  ```yaml
  name: **Example 1 - Runner timeout bigger than project timeout**
    project_timeout: 2h
    runner_timeout: 24h
    job_timeout: 4h
    resulting_timeout: 4h
  
  name: **Example 2 - Runner timeout not configured**
    project_timeout: 2h
    job_timeout: 4h
    resulting_timeout: 4h
  
  name: **Example 3 - Runner AND job timeout are not configured**
    project_timeout: 24h
    resulting_timeout: 24h
  
  name: **Example 4 - Runner timeout smaller than project timeout**
    project_timeout: 2h
    runner_timeout: 30m
    resulting_timeout: 30m
  
  name: **Example 5 - Runner timeout smaller than Project timeout, Job timeout is bigger than Runner timeout**
    project_timeout: 2h
    runner_timeout: 30m
    job_timeout: 1h
    resulting_timeout: 30m
  
  ```
  
  > **Comments:**
  > **username_0**: thanks for your reply, but as far as I understand these are all runtime timeout, limiting the time a job can effectively run after it is started. But my problem, as I tried to explain in my original post, is that my jobs die because they are not started due to unavailable runners, since my only runner runs one job at each time and the others are killed while waiting to be run. Maybe your reply effectively provides a solution for this case but I misunderstood it?  
  > **username_2**: Hi, @username_0-username_0. Just set `Project timeout` to value more than 3h. And leave `Runner timeout` value empty. See `Example 3`  
  > **username_0**: Hi, my Project timeout (i.e. that configured in Settings -> CI / CD Settings -> General pipelines -> Timeout) is currently 2d, and my runner does not have a timeout. Does this correspond to what you are suggesting? Or do  have to put the settings you are suggesting somewhere (I guess in .gitlab-ci.yml)? Sorry for the noob questions but I'm a beginner...  
  > **username_2**: Hi. Please show your `.gitlab-ci.yml`  
  > **username_0**: You can find it here: https://basket.fi.infn.it:443/f/0de7f11b48/?dl=1  
  > **username_2**: Sorry, nothing to say  
  
  ---
  
  