diff options
Diffstat (limited to 'doc/ci/runners/configure_runners.md')
-rw-r--r-- | doc/ci/runners/configure_runners.md | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/doc/ci/runners/configure_runners.md b/doc/ci/runners/configure_runners.md index fd1716cc58a..bca0b50563a 100644 --- a/doc/ci/runners/configure_runners.md +++ b/doc/ci/runners/configure_runners.md @@ -27,7 +27,9 @@ On GitLab.com, you cannot override the job timeout for shared runners and must u To set the maximum job timeout: -1. In a project, go to **Settings > CI/CD > Runners**. +1. On the left sidebar, select **Search or go to** and find your project. +1. Select **Settings > CI/CD**. +1. Expand **Runners**. 1. Select your project runner to edit the settings. 1. Enter a value under **Maximum job timeout**. Must be 10 minutes or more. If not defined, the [project's job timeout setting](../pipelines/settings.md#set-a-limit-for-how-long-jobs-can-run) @@ -57,6 +59,45 @@ How this feature works: 1. You start a job 1. The job, if running longer, times out after **30 minutes** +## Set `script` and `after_script` timeouts + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/4335) in GitLab Runner 16.4. + +To control the amount of time `script` and `after_script` runs before it terminates, you can set specify a timeout. + +For example, you can specify a timeout to terminate a long-running `script` early, so that artifacts and caches can still be uploaded +before the [job timeout](#set-maximum-job-timeout-for-a-runner) is exceeded. + +- To set a timeout for `script`, use the job variable `RUNNER_SCRIPT_TIMEOUT`. +- To set a timeout for `after_script`, and override the default of 5 minutes, use the job variable `RUNNER_AFTER_SCRIPT_TIMEOUT`. + +Both of these variables accept [Go's duration format](https://pkg.go.dev/time#ParseDuration) (for example, `40s`, `1h20m`, `2h` `4h30m30s`). + +For example: + +```yaml +job-with-script-timeouts: + variables: + RUNNER_SCRIPT_TIMEOUT: 15m + RUNNER_AFTER_SCRIPT_TIMEOUT: 10m + script: + - "I am allowed to run for min(15m, remaining job timeout)." + after_script: + - "I am allowed to run for min(10m, remaining job timeout)." + +job-artifact-upload-on-timeout: + timeout: 1h # set job timeout to 1 hour + variables: + RUNNER_SCRIPT_TIMEOUT: 50m # only allow script to run for 50 minutes + script: + - long-running-process > output.txt # will be terminated after 50m + + artifacts: # artifacts will have roughly ~10m to upload + paths: + - output.txt + when: on_failure # on_failure because script termination after a timeout is treated as a failure +``` + ## Protecting sensitive information To avoid exposing sensitive information, you can restrict the usage @@ -155,11 +196,13 @@ To change this, you must have the Owner role for the project. To make a runner pick untagged jobs: -1. Go to the project's **Settings > CI/CD** and expand the **Runners** section. +1. On the left sidebar, select **Search or go to** and find your project. +1. Select **Settings > CI/CD**. +1. Expand **Runners**. 1. Find the runner you want to pick untagged jobs and make sure it's enabled. -1. Select the pencil button. -1. Check the **Run untagged jobs** option. -1. Select **Save changes** for the changes to take effect. +1. Select **Edit** (**{pencil}**). +1. Select the **Run untagged jobs** checkbox. +1. Select **Save changes**. NOTE: The runner tags list cannot be empty when it's not allowed to pick untagged jobs. @@ -545,7 +588,7 @@ You can specify the depth of fetching and cloning using `GIT_DEPTH`. It can be helpful for repositories with a large number of commits or old, large binaries. The value is passed to `git fetch` and `git clone`. -In GitLab 12.0 and later, newly-created projects automatically have a +Newly-created projects automatically have a [default `git depth` value of `50`](../pipelines/settings.md#limit-the-number-of-changes-fetched-during-clone). If you use a depth of `1` and have a queue of jobs or retry @@ -677,7 +720,7 @@ the following stages: | Variable | Description | |---------------------------------|--------------------------------------------------------| | `ARTIFACT_DOWNLOAD_ATTEMPTS` | Number of attempts to download artifacts running a job | -| `EXECUTOR_JOB_SECTION_ATTEMPTS` | In [GitLab 12.10 and later](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4450), the number of attempts to run a section in a job after a [`No Such Container`](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4450) error ([Docker executor](https://docs.gitlab.com/runner/executors/docker.html) only). | +| `EXECUTOR_JOB_SECTION_ATTEMPTS` | The number of attempts to run a section in a job after a [`No Such Container`](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4450) error ([Docker executor](https://docs.gitlab.com/runner/executors/docker.html) only). | | `GET_SOURCES_ATTEMPTS` | Number of attempts to fetch sources running a job | | `RESTORE_CACHE_ATTEMPTS` | Number of attempts to restore the cache running a job | @@ -898,7 +941,7 @@ Prerequisites: To automatically rotate runner authentication tokens: 1. On the left sidebar, select **Search or go to**. -1. Select **Admin Area**.. +1. Select **Admin Area**. 1. On the left sidebar, select **Settings > CI/CD**. 1. Expand **Continuous Integration and Deployment** 1. Set a **Runners expiration** time for runners, leave empty for no expiration. |