gitlab.com/jfprevost/gitlab-runner-notlscheck@v11.11.4+incompatible/docs/configuration/advanced-configuration.md (about)

     1  ---
     2  table_display_block: true
     3  ---
     4  
     5  # Advanced configuration
     6  
     7  GitLab Runner configuration uses the [TOML][] format.
     8  
     9  The file to be edited can be found in:
    10  
    11  1. `/etc/gitlab-runner/config.toml` on \*nix systems when gitlab-runner is
    12     executed as root (**this is also path for service configuration**)
    13  1. `~/.gitlab-runner/config.toml` on \*nix systems when gitlab-runner is
    14     executed as non-root
    15  1. `./config.toml` on other systems
    16  
    17  ## The global section
    18  
    19  This defines global settings of GitLab Runner.
    20  
    21  | Setting | Description |
    22  | ------- | ----------- |
    23  | `concurrent`     | limits how many jobs globally can be run concurrently. The most upper limit of jobs using all defined runners. `0` **does not** mean unlimited |
    24  | `log_level`      | Log level (options: debug, info, warn, error, fatal, panic). Note that this setting has lower priority than level set by command line argument `--debug`, `-l` or `--log-level` |
    25  | `log_format`     | Log format (options: runner, text, json). Note that this setting has lower priority than format set by command line argument `--log-format` |
    26  | `check_interval` | defines the interval length, in seconds, between new jobs check. The default value is `3`; if set to `0` or lower, the default value will be used. |
    27  | `sentry_dsn`     | enable tracking of all system level errors to sentry |
    28  | `listen_address` | address (`<host>:<port>`) on which the Prometheus metrics HTTP server should be listening |
    29  
    30  Example:
    31  
    32  ```bash
    33  concurrent = 4
    34  log_level = "warning"
    35  ```
    36  
    37  ### How `check_interval` works
    38  
    39  If there is more than one `[[runners]]` section in `config.toml` (let's call them workers),
    40  the interval between requests to GitLab are more frequent than one could expect. GitLab Runner
    41  contains a loop that constantly schedules a request that should be made for a worker against
    42  the GitLab instance it's configured for.
    43  
    44  GitLab Runner tries to ensure that subsequent requests for one worker will be done in the specified interval,
    45  so the value of `check_interval` is divided by the number of the `[[runners]]` sections. The loop will next
    46  iterate over all sections, schedule a request for each of them, and will sleep for the calculated amount
    47  of time. Things get interesting when the workers are tied to a different GitLab instance.
    48  Consider the following example.
    49  
    50  If one would set `check_interval = 10`, and there were 2 workers in total (`runner-1` and `runner-2`),
    51  a subsequent request would be made each 10 seconds. The loop would look like:
    52  
    53  1. Get `check_interval` value (`10s`).
    54  1. Get list of workers (`runner-1`, `runner-2`).
    55  1. Calculate the sleep interval (`10s / 2 = 5s`).
    56  1. Start an infinite loop:
    57      1. Request a job for `runner-1`.
    58      1. Sleep for `5s`.
    59      1. Request a job for `runner-2`.
    60      1. Sleep for `5s`.
    61      1. Repeat.
    62  
    63  So, a request from the Runner's process is made each 5s. If `runner-1` and `runner-2` are connected to the same
    64  GitLab instance, it means that the request to this GitLab instance will receive a new request from this Runner
    65  also each 5s. But as you can see, between the first request for `runner-1` and second request for `runner-1`
    66  there are two sleeps taking 5s, so finally it's ~10s between subsequent requests for `runner-1`. The same goes
    67  for `runner-2`. If you define more workers, the sleep interval will be smaller, but a request for a worker will
    68  be repeated after all requests for the other workers + their sleeps are called.
    69  
    70  ## The `[session_server]` section
    71  
    72  The section `[session_server]` is a system runner level configuration, so it should be specified at the root level,
    73  not per executor i.e. it should be outside `[[runners]]` section. The session server allows the user to interact
    74  with jobs that the Runner is responsible for. A good example of this is the
    75  [interactive web terminal](https://docs.gitlab.com/ee/ci/interactive_web_terminal).
    76  
    77  Both `listen_address` and `advertise_address` should be provided in the form
    78  of `host:port`, where `host` may be an IP address (e.g., `127.0.0.1:8093`)
    79  or a domain (e.g., `my-runner.example.com:8093`). The Runner will create a
    80  TLS certificate automatically to have a secure connection.
    81  
    82  If you want to disable the session server, just delete the `[session_server]`
    83  section and terminal support will be disabled.
    84  
    85  | Setting | Description |
    86  | ------- | ----------- |
    87  | `listen_address` | An internal URL to be used for the session server. |
    88  | `advertise_address`| The URL that the Runner will expose to GitLab to be used to access the session server. Fallbacks to `listen_address` if not defined.   |
    89  | `session_timeout` | How long in seconds the session can stay active after the job completes (which will block the job from finishing), defaults to `1800` (30 minutes). |
    90  
    91  Example:
    92  
    93  ```bash
    94  [session_server]
    95    listen_address = "0.0.0.0:8093" #  listen on all available interfaces on port 8093
    96    advertise_address = "runner-host-name.tld:8093"
    97    session_timeout = 1800
    98  ```
    99  
   100  ## The `[[runners]]` section
   101  
   102  This defines one runner entry.
   103  
   104  | Setting | Description |
   105  | ------- | ----------- |
   106  | `name`               | The Runner's description, just informatory |
   107  | `url`                | GitLab URL |
   108  | `token`              | The Runner's special token (not to be confused with the registration token) |
   109  | `tls-ca-file`        | File containing the certificates to verify the peer when using HTTPS |
   110  | `tls-cert-file`      | File containing the certificate to authenticate with the peer when using HTTPS |
   111  | `tls-key-file`       | File containing the private key to authenticate with the peer when using HTTPS |
   112  | `limit`              | Limit how many jobs can be handled concurrently by this token. `0` (default) simply means don't limit |
   113  | `executor`           | Select how a project should be built, see next section |
   114  | `shell`              | Name of shell to generate the script. Default value is [platform dependent](../shells/index.md#overview). |
   115  | `builds_dir`         | Directory where builds will be stored in context of selected executor (Locally, Docker, SSH) |
   116  | `cache_dir`          | Directory where build caches will be stored in context of selected executor (locally, Docker, SSH). If the `docker` executor is used, this directory needs to be included in its `volumes` parameter. |
   117  | `environment`        | Append or overwrite environment variables |
   118  | `request_concurrency` | Limit number of concurrent requests for new jobs from GitLab (default 1) |
   119  | `output_limit`       | Set maximum build log size in kilobytes, by default set to 4096 (4MB) |
   120  | `pre_clone_script`   | Commands to be executed on the Runner before cloning the Git repository. this can be used to adjust the Git client configuration first, for example. To insert multiple commands, use a (triple-quoted) multi-line string or "\n" character. |
   121  | `pre_build_script`   | Commands to be executed on the Runner after cloning the Git repository, but before executing the build. To insert multiple commands, use a (triple-quoted) multi-line string or "\n" character. |
   122  | `post_build_script`  | Commands to be executed on the Runner just after executing the build, but before executing `after_script`. To insert multiple commands, use a (triple-quoted) multi-line string or "\n" character. |
   123  | `clone_url`          | Overwrite the URL for the GitLab instance. Used if the Runner can't connect to GitLab on the URL GitLab exposes itself. |
   124  | `debug_trace_disabled` | Disables the `CI_DEBUG_TRACE` feature. When set to true, then debug trace will remain disabled even if `CI_DEBUG_TRACE` will be set to `true` by the user. |
   125  
   126  Example:
   127  
   128  ```bash
   129  [[runners]]
   130    name = "ruby-2.1-docker"
   131    url = "https://CI/"
   132    token = "TOKEN"
   133    limit = 0
   134    executor = "docker"
   135    builds_dir = ""
   136    shell = ""
   137    environment = ["ENV=value", "LC_ALL=en_US.UTF-8"]
   138    clone_url = "http://gitlab.example.local"
   139  ```
   140  
   141  ### How `clone_url` works
   142  
   143  In cases where the GitLab instance is exposed to an URL which can't be used
   144  by the runner, a `clone_url` can be configured. For example; GitLab is exposed
   145  to `https://gitlab.example.com`, but the runner can't reach that because of
   146  a firewall setup. If the runner can reach the node on `192.168.1.23`,
   147  the `clone_url` should be set to `"http://192.168.1.23`.
   148  
   149  Only if the `clone_url` is set, the runner will construct a clone URL in the form
   150  of `http://gitlab-ci-token:s3cr3tt0k3n@192.168.1.23/namespace/project.git`.
   151  
   152  ## The EXECUTORS
   153  
   154  There are a couple of available executors currently.
   155  
   156  | Executor | Description |
   157  | -------- | ----------- |
   158  | `shell`       | run build locally, default |
   159  | `docker`      | run build using Docker container - this requires the presence of `[runners.docker]` and [Docker Engine][] installed on the system that the Runner runs |
   160  | `docker-windows` | run build using Windows Docker container. This requires the presence of `[runners.docker]` and [Docker Engine][] installed on a Windows system. |
   161  | `docker-ssh`  | run build using Docker container, but connect to it with SSH - this requires the presence of `[runners.docker]` , `[runners.ssh]` and [Docker Engine][] installed on the system that the Runner runs. **Note: This will run the docker container on the local machine, it just changes how the commands are run inside that container. If you want to run docker commands on an external machine, then you should change the `host` parameter in the `runners.docker` section.**|
   162  | `ssh`         | run build remotely with SSH - this requires the presence of `[runners.ssh]` |
   163  | `parallels`   | run build using Parallels VM, but connect to it with SSH - this requires the presence of `[runners.parallels]` and `[runners.ssh]` |
   164  | `virtualbox`  | run build using VirtualBox VM, but connect to it with SSH - this requires the presence of `[runners.virtualbox]` and `[runners.ssh]` |
   165  | `docker+machine` | like `docker`, but uses [auto-scaled Docker machines](autoscale.md) - this requires the presence of `[runners.docker]` and `[runners.machine]` |
   166  | `docker-ssh+machine` | like `docker-ssh`, but uses [auto-scaled Docker machines](autoscale.md) - this requires the presence of `[runners.docker]` and `[runners.machine]` |
   167  | `kubernetes` | run build using Kubernetes Pods - this requires the presence of `[runners.kubernetes]` |
   168  
   169  ## The SHELLS
   170  
   171  There are a couple of available shells that can be run on different platforms.
   172  
   173  | Shell | Description |
   174  | ----- | ----------- |
   175  | `bash`        | generate Bash (Bourne-shell) script. All commands executed in Bash context (default for all Unix systems) |
   176  | `sh`          | generate Sh (Bourne-shell) script. All commands executed in Sh context (fallback for `bash` for all Unix systems) |
   177  | `cmd`         | generate Windows Batch script. All commands are executed in Batch context (default for Windows) |
   178  | `powershell`  | generate Windows PowerShell script. All commands are executed in PowerShell context |
   179  
   180  ## The `[runners.docker]` section
   181  
   182  This defines the Docker Container parameters.
   183  
   184  | Parameter | Description |
   185  | --------- | ----------- |
   186  | `host`                         | Specify custom Docker endpoint, by default `DOCKER_HOST` environment is used or `unix:///var/run/docker.sock` |
   187  | `hostname`                     | Specify custom hostname for Docker container |
   188  | `runtime`                      | Specify a runtime for Docker container |
   189  | `tls_cert_path`                | When set it will use `ca.pem`, `cert.pem` and `key.pem` from that folder to make secure TLS connection to Docker (useful in boot2docker) |
   190  | `image`                        | Use this image to run builds |
   191  | `memory`                       | String value containing the memory limit |
   192  | `memory_swap`                  | String value containing the total memory limit |
   193  | `memory_reservation`           | String value containing the memory soft limit |
   194  | `oom_kill_disable`             | Do not kill processes in a container if an out-of-memory (OOM) error occurs |
   195  | `cpuset_cpus`                  | String value containing the cgroups CpusetCpus to use |
   196  | `cpus`                         | Number of CPUs (available in docker 1.13 or later) |
   197  | `dns`                          | A list of DNS servers for the container to use |
   198  | `dns_search`                   | A list of DNS search domains |
   199  | `privileged`                   | Make container run in Privileged mode (insecure) |
   200  | `disable_entrypoint_overwrite` | Disable the image entrypoint overwriting |
   201  | `userns_mode`                  | Sets the usernamespace mode for the container when usernamespace remapping option is enabled. (available in docker 1.10 or later) |
   202  | `cap_add`                      | Add additional Linux capabilities to the container |
   203  | `cap_drop`                     | Drop additional Linux capabilities from the container |
   204  | `security_opt`                 | Set security options (--security-opt in docker run), takes a list of ':' separated key/values |
   205  | `devices`                      | Share additional host devices with the container |
   206  | `cache_dir`                    | Specify where Docker caches should be stored (this can be absolute or relative to current working directory). See `disable_cache` for more information. |
   207  | `disable_cache`                | The Docker executor has 2 levels of caching: a global one (like any other executor) and a local cache based on Docker volumes. This configuration flag acts only on the local one which disables the use of automatically created (not mapped to a host directory) cache volumes. In other words, it only prevents creating a container that holds temporary files of builds, it does not disable the cache if the Runner is configured in [distributed cache mode](autoscale.md#distributed-runners-caching). |
   208  | `network_mode`              | Add container to a custom network |
   209  | `wait_for_services_timeout` | Specify how long to wait for docker services, set to 0 to disable, default: 30 |
   210  | `volumes`                   | Specify additional volumes that should be mounted (same syntax as Docker's `-v` flag) |
   211  | `extra_hosts`               | Specify hosts that should be defined in container environment |
   212  | `shm_size`                  | Specify shared memory size for images (in bytes) |
   213  | `volumes_from`              | Specify a list of volumes to inherit from another container in the form `\<container name\>[:\<ro&#124;rw\>]` |
   214  | `volume_driver`             | Specify the volume driver to use for the container |
   215  | `links`                     | Specify containers which should be linked with building container |
   216  | `services`                  | Specify additional services that should be run with build. Please visit [Docker Registry](https://registry.hub.docker.com/) for list of available applications. Each service will be run in separate container and linked to the build. |
   217  | `allowed_images`            | Specify wildcard list of images that can be specified in .gitlab-ci.yml. If not present all images are allowed (equivalent to `["*/*:*"]`) |
   218  | `allowed_services`          | Specify wildcard list of services that can be specified in .gitlab-ci.yml. If not present all images are allowed (equivalent to `["*/*:*"]`) |
   219  | `pull_policy`               | Specify the image pull policy: `never`, `if-not-present` or `always` (default); read more in the [pull policies documentation](../executors/docker.md#how-pull-policies-work) |
   220  | `sysctls`                   | specify the sysctl options |
   221  | `helper_image`              | [ADVANCED] Override the default helper image used to clone repos and upload artifacts. Read the [helper image](#helper-image) section for more details |
   222  
   223  Example:
   224  
   225  ```bash
   226  [runners.docker]
   227    host = ""
   228    hostname = ""
   229    tls_cert_path = "/Users/ayufan/.boot2docker/certs"
   230    image = "ruby:2.1"
   231    memory = "128m"
   232    memory_swap = "256m"
   233    memory_reservation = "64m"
   234    oom_kill_disable = false
   235    cpuset_cpus = "0,1"
   236    dns = ["8.8.8.8"]
   237    dns_search = [""]
   238    privileged = false
   239    userns_mode = "host"
   240    cap_add = ["NET_ADMIN"]
   241    cap_drop = ["DAC_OVERRIDE"]
   242    devices = ["/dev/net/tun"]
   243    disable_cache = false
   244    wait_for_services_timeout = 30
   245    cache_dir = ""
   246    volumes = ["/data", "/home/project/cache"]
   247    extra_hosts = ["other-host:127.0.0.1"]
   248    shm_size = 300000
   249    volumes_from = ["storage_container:ro"]
   250    links = ["mysql_container:mysql"]
   251    services = ["mysql", "redis:2.8", "postgres:9"]
   252    allowed_images = ["ruby:*", "python:*", "php:*"]
   253    allowed_services = ["postgres:9.4", "postgres:latest"]
   254    [runners.docker.sysctls]
   255      "net.ipv4.ip_forward" = "1"
   256  ```
   257  
   258  ### Volumes in the `[runners.docker]` section
   259  
   260  You can find the complete guide of Docker volume usage
   261  [here](https://docs.docker.com/userguide/dockervolumes/).
   262  
   263  Let's use some examples to explain how it work (assuming you have a working
   264  runner).
   265  
   266  #### Example 1: adding a data volume
   267  
   268  A data volume is a specially-designated directory within one or more containers
   269  that bypasses the Union File System. Data volumes are designed to persist data,
   270  independent of the container's life cycle.
   271  
   272  ```bash
   273  [runners.docker]
   274    host = ""
   275    hostname = ""
   276    tls_cert_path = "/Users/ayufan/.boot2docker/certs"
   277    image = "ruby:2.1"
   278    privileged = false
   279    disable_cache = true
   280    volumes = ["/path/to/volume/in/container"]
   281  ```
   282  
   283  This will create a new volume inside the container at `/path/to/volume/in/container`.
   284  
   285  #### Example 2: mount a host directory as a data volume
   286  
   287  In addition to creating a volume using you can also mount a directory from your
   288  Docker daemon's host into a container. It's useful when you want to store
   289  builds outside the container.
   290  
   291  ```bash
   292  [runners.docker]
   293    host = ""
   294    hostname = ""
   295    tls_cert_path = "/Users/ayufan/.boot2docker/certs"
   296    image = "ruby:2.1"
   297    privileged = false
   298    disable_cache = true
   299    volumes = ["/path/to/bind/from/host:/path/to/bind/in/container:rw"]
   300  ```
   301  
   302  This will use `/path/to/bind/from/host` of the CI host inside the container at
   303  `/path/to/bind/in/container`.
   304  
   305  ### Using a private container registry
   306  
   307  > **Notes:**
   308  >- This feature requires GitLab Runner **1.8** or higher
   309  >- For GitLab Runner versions **>= 0.6, <1.8** there was a partial
   310    support for using private registries, which required manual configuration
   311    of credentials on runner's host. We recommend to upgrade your Runner to
   312    at least version **1.8** if you want to use private registries.
   313  >- Using private registries with the `if-not-present` pull policy may introduce
   314    [security implications][secpull]. To fully understand how pull policies work,
   315    read the [pull policies documentation](../executors/docker.md#how-pull-policies-work).
   316  
   317  If you want to use private registries as a source of images for your builds,
   318  you can set the authorization configuration in the `DOCKER_AUTH_CONFIG`
   319  [variable]. It can be set in both GitLab Variables section of
   320  a project and in the `config.toml` file.
   321  
   322  For a detailed example, visit the [Using Docker images documentation][priv-example].
   323  
   324  The steps performed by the Runner can be summed up to:
   325  
   326  1. The registry name is found from the image name.
   327  1. If the value is not empty, the executor will search for the authentication
   328     configuration for this registry.
   329  1. Finally, if an authentication corresponding to the specified registry is
   330     found, subsequent pulls will make use of it.
   331  
   332  Now that the Runner is set up to authenticate against your private registry,
   333  learn [how to configure .gitlab-ci.yml][yaml-priv-reg] in order to use that
   334  registry.
   335  
   336  #### Support for GitLab integrated registry
   337  
   338  > **Note:**
   339  To work automatically with private/protected images from
   340  GitLab integrated registry it needs at least GitLab CE/EE **8.14**
   341  and GitLab Runner **1.8**.
   342  
   343  Starting with GitLab CE/EE 8.14, GitLab will send credentials for its integrated
   344  registry along with the build data. These credentials will be automatically
   345  added to registries authorization parameters list.
   346  
   347  After this authorization against the registry will be proceed like for
   348  configuration added with `DOCKER_AUTH_CONFIG` variable.
   349  
   350  Thanks to this, in your builds you can use any image from you GitLab integrated
   351  registry, even if the image is private/protected. To fully understand for
   352  which images the builds will have access, read the
   353  [New CI build permissions model][ci-build-permissions-model] documentation.
   354  
   355  #### Precedence of Docker authorization resolving
   356  
   357  As described above, GitLab Runner can authorize Docker against a registry by
   358  using credentials sent in different way. To find a proper registry, the following
   359  precedence is taken into account:
   360  
   361  1. Credentials configured with `DOCKER_AUTH_CONFIG`.
   362  1. Credentials configured locally on Runner's host with `~/.docker/config.json`
   363     or `~/.dockercfg` files (e.g., by running `docker login` on the host).
   364  1. Credentials sent by default with job's payload (e.g., credentials for _integrated
   365     registry_ described above).
   366  
   367  The first found credentials for the registry will be used. So for example,
   368  if you add some credentials for the _integrated registry_ with the
   369  `DOCKER_AUTH_CONFIG` variable, then the default credentials will be overridden.
   370  
   371  #### Restrict `allowed_images` to private registry
   372  
   373  For certain setups you will restrict access of the build jobs to docker images
   374  which comes from your private docker registry. In that case set
   375  
   376  ```bash
   377  [runners.docker]
   378    ...
   379    allowed_images = ["my.registry.tld:5000/*:*"]
   380  ```
   381  
   382  ## The `[runners.parallels]` section
   383  
   384  This defines the Parallels parameters.
   385  
   386  | Parameter | Description |
   387  | --------- | ----------- |
   388  | `base_name`         | name of Parallels VM which will be cloned |
   389  | `template_name`     | custom name of Parallels VM linked template (optional) |
   390  | `disable_snapshots` | if disabled the VMs will be destroyed after build |
   391  
   392  Example:
   393  
   394  ```bash
   395  [runners.parallels]
   396    base_name = "my-parallels-image"
   397    template_name = ""
   398    disable_snapshots = false
   399  ```
   400  
   401  ## The `[runners.virtualbox]` section
   402  
   403  This defines the VirtualBox parameters. This executor relies on
   404  `vboxmanage` as executable to control VirtualBox machines so you have to adjust
   405  your `PATH` environment variable on Windows hosts:
   406  `PATH=%PATH%;C:\Program Files\Oracle\VirtualBox`.
   407  
   408  | Parameter | Explanation |
   409  | --------- | ----------- |
   410  | `base_name`         | name of VirtualBox VM which will be cloned |
   411  | `base_snapshot`     | name or UUID of a specific snapshot of the VM from which to create a linked clone. If this is empty or omitted, the current snapshot will be used. If there is no current snapshot, one will be created unless `disable_snapshots` is true, in which case a full clone of the base VM will be made. |
   412  | `disable_snapshots` | if disabled the VMs will be destroyed after build |
   413  
   414  Example:
   415  
   416  ```bash
   417  [runners.virtualbox]
   418    base_name = "my-virtualbox-image"
   419    base_snapshot = "my-image-snapshot"
   420    disable_snapshots = false
   421  ```
   422  
   423  ## The `[runners.ssh]` section
   424  
   425  This defines the SSH connection parameters.
   426  
   427  | Parameter  | Description |
   428  | ---------- | ----------- |
   429  | `host`     | where to connect (overridden when using `docker-ssh`) |
   430  | `port`     | specify port, default: 22 |
   431  | `user`     | specify user |
   432  | `password` | specify password |
   433  | `identity_file` | specify file path to SSH private key (id_rsa, id_dsa or id_edcsa). The file needs to be stored unencrypted |
   434  
   435  Example:
   436  
   437  ```
   438  [runners.ssh]
   439    host = "my-production-server"
   440    port = "22"
   441    user = "root"
   442    password = "production-server-password"
   443    identity_file = ""
   444  ```
   445  
   446  ## The `[runners.machine]` section
   447  
   448  > Added in GitLab Runner v1.1.0.
   449  
   450  This defines the Docker Machine based autoscaling feature. More details can be
   451  found in the separate [runners autoscale documentation](autoscale.md).
   452  
   453  | Parameter           | Description |
   454  |---------------------|-------------|
   455  | `IdleCount`         | Number of machines, that need to be created and waiting in _Idle_ state. |
   456  | `IdleTime`          | Time (in seconds) for machine to be in _Idle_ state before it is removed. |
   457  | `OffPeakPeriods`    | Time periods when the scheduler is in the OffPeak mode. An array of cron-style patterns (described below). |
   458  | `OffPeakTimezone`   | Time zone for the times given in OffPeakPeriods. A timezone string like Europe/Berlin (defaults to the locale system setting of the host if omitted or empty). |
   459  | `OffPeakIdleCount`  | Like `IdleCount`, but for _Off Peak_ time periods. |
   460  | `OffPeakIdleTime`   | Like `IdleTime`, but for _Off Peak_ time mperiods. |
   461  | `MaxBuilds`         | Builds count after which machine will be removed. |
   462  | `MachineName`       | Name of the machine. It **must** contain `%s`, which will be replaced with a unique machine identifier. |
   463  | `MachineDriver`     | Docker Machine `driver` to use. More details can be found in the [Docker Machine configuration section](autoscale.md#supported-cloud-providers). |
   464  | `MachineOptions`    | Docker Machine options. More details can be found in the [Docker Machine configuration section](autoscale.md#supported-cloud-providers). |
   465  
   466  Example:
   467  
   468  ```bash
   469  [runners.machine]
   470    IdleCount = 5
   471    IdleTime = 600
   472    OffPeakPeriods = [
   473      "* * 0-10,18-23 * * mon-fri *",
   474      "* * * * * sat,sun *"
   475    ]
   476    OffPeakTimezone = "Europe/Berlin"
   477    OffPeakIdleCount = 1
   478    OffPeakIdleTime = 3600
   479    MaxBuilds = 100
   480    MachineName = "auto-scale-%s"
   481    MachineDriver = "digitalocean"
   482    MachineOptions = [
   483        "digitalocean-image=coreos-stable",
   484        "digitalocean-ssh-user=core",
   485        "digitalocean-access-token=DO_ACCESS_TOKEN",
   486        "digitalocean-region=nyc2",
   487        "digitalocean-size=4gb",
   488        "digitalocean-private-networking",
   489        "engine-registry-mirror=http://10.11.12.13:12345"
   490    ]
   491  ```
   492  
   493  ### OffPeakPeriods syntax
   494  
   495  The `OffPeakPeriods` setting contains an array of string patterns of
   496  time periods represented in a cron-style format. The line contains
   497  following fields:
   498  
   499  ```
   500  [second] [minute] [hour] [day of month] [month] [day of week] [year]
   501  ```
   502  
   503  Like in the standard cron configuration file, the fields can contain single
   504  values, ranges, lists and asterisks. A detailed description of the syntax
   505  can be found [here][cronvendor].
   506  
   507  ## The `[runners.cache]` section
   508  
   509  > Introduced in GitLab Runner 1.1.0.
   510  
   511  This defines the distributed cache feature. More details can be found
   512  in the [runners autoscale documentation](autoscale.md#distributed-runners-caching).
   513  
   514  | Parameter        | Type             | Description |
   515  |------------------|------------------|-------------|
   516  | `Type`           | string           | One of: `s3`, `gcs`. |
   517  | `Path`           | string           | Name of the path to prepend to the cache URL. |
   518  | `Shared`         | boolean          | Enables cache sharing between runners, `false` by default. |
   519  
   520  CAUTION: **Important:**
   521  With GitLab Runner 11.3.0, the configuration parameters related to S3 were moved to a dedicated `[runners.cache.s3]` section.
   522  The old format of the configuration with S3 configured directly in `[runners.cache]` section is still supported,
   523  but is deprecated with GitLab Runner 11.3.0. **This support will be removed in GitLab Runner 12.0.0**.
   524  
   525  NOTE: **Note:**
   526  The cache mechanism uses pre-signed URLs to upload and download cache. URLs are being signed by GitLab Runner on its **own instance**.
   527  No matter if the job's script - so also the cache upload/download script - are being executed on local or external
   528  machines (e.g. `shell` or `docker` executors are running their scripts on the same
   529  machine where GitLab Runner process is running, while `virtualbox` or `docker+machine`
   530  connects to a separate VM to execute the script). This is done for security reasons:
   531  minimizing the possibility of leaking the cache adapter's credentials.
   532  
   533  NOTE: **Note:**
   534  Previous note implies [S3 cache adapter](#the-runnerscaches3-section), if configured to use
   535  IAM instance profile, will use the profile attached with GitLab Runner's machine.
   536  Similarly for [GCS cache adapter](#the-runnerscachegcs-section), if configured to
   537  use the `CredentialsFile`, the file needs to be present on GitLab Runner's machine.
   538  
   539  Below is a table containing a summary of `config.toml`, cli options and ENV variables deprecations:
   540  
   541  | Setting             | TOML field                               | CLI option for `register`      | ENV for `register`                | deprecated TOML field               | deprecated CLI option   | deprecated ENV        |
   542  |---------------------|------------------------------------------|--------------------------------|-----------------------------------|-------------------------------------|-------------------------|-----------------------|
   543  | Type                | `[runners.cache] -> Type`                | `--cache-type`                 | `$CACHE_TYPE`                     |                                     |                         |                       |
   544  | Path                | `[runners.cache] -> Path`                | `--cache-path`                 | `$CACHE_PATH`                     |                                     | `--cache-s3-cache-path` | `$S3_CACHE_PATH`      |
   545  | Shared              | `[runners.cache] -> Shared`              | `--cache-shared`               | `$CACHE_SHARED`                   |                                     | `--cache-cache-shared`  |                       |
   546  | S3.ServerAddress    | `[runners.cache.s3] -> ServerAddress`    | `--cache-s3-server-address`    | `$CACHE_S3_SERVER_ADDRESS`        | `[runners.cache] -> ServerAddress`  |                         | `$S3_SERVER_ADDRESS`  |
   547  | S3.AccessKey        | `[runners.cache.s3] -> AccessKey`        | `--cache-s3-access-key`        | `$CACHE_S3_ACCESS_KEY`            | `[runners.cache] -> AccessKey`      |                         | `$S3_ACCESS_KEY`      |
   548  | S3.SecretKey        | `[runners.cache.s3] -> SecretKey`        | `--cache-s3-secret-key`        | `$CACHE_S3_SECRET_KEY`            | `[runners.cache] -> SecretKey`      |                         | `$S3_SECRET_KEY`      |
   549  | S3.BucketName       | `[runners.cache.s3] -> BucketName`       | `--cache-s3-bucket-name`       | `$CACHE_S3_BUCKET_NAME`           | `[runners.cache] -> BucketName`     |                         | `$S3_BUCKET_NAME`     |
   550  | S3.BucketLocation   | `[runners.cache.s3] -> BucketLocation`   | `--cache-s3-bucket-location`   | `$CACHE_S3_BUCKET_LOCATION`       | `[runners.cache] -> BucketLocation` |                         | `$S3_BUCKET_LOCATION` |
   551  | S3.Insecure         | `[runners.cache.s3] -> Insecure`         | `--cache-s3-insecure`          | `$CACHE_S3_INSECURE`              | `[runners.cache] -> Insecure`       |                         | `$S3_INSECURE`        |
   552  | GCS.AccessID        | `[runners.cache.gcs] -> AccessID`        | `--cache-gcs-access-id`        | `$CACHE_GCS_ACCESS_ID`            |                                     |                         |                       |
   553  | GCS.PrivateKey      | `[runners.cache.gcs] -> PrivateKey`      | `--cache-gcs-private-key`      | `$CACHE_GCS_PRIVATE_KEY`          |                                     |                         |                       |
   554  | GCS.CredentialsFile | `[runners.cache.gcs] -> CredentialsFile` | `--cache-gcs-credentials-file` | `$GOOGLE_APPLICATION_CREDENTIALS` |                                     |                         |                       |
   555  | GCS.BucketName      | `[runners.cache.gcs] -> BucketName`      | `--cache-gcs-bucket-name`      | `$CACHE_GCS_BUCKET_NAME`          |                                     |                         |                       |
   556  
   557  ### The `[runners.cache.s3]` section
   558  
   559  NOTE: **Note:**
   560  Moved from the `[runners.cache]` section in GitLab Runner 11.3.0.
   561  
   562  Allows to configure S3 storage for cache. This section contains settings related to S3, that previously were
   563  present globally in the `[runners.cache]` section.
   564  
   565  | Parameter        | Type             | Description |
   566  |------------------|------------------|-------------|
   567  | `ServerAddress`  | string           | A `host:port` to the used S3-compatible server. |
   568  | `AccessKey`      | string           | The access key specified for your S3 instance. |
   569  | `SecretKey`      | string           | The secret key specified for your S3 instance. |
   570  | `BucketName`     | string           | Name of the storage bucket where cache will be stored. |
   571  | `BucketLocation` | string           | Name of S3 region. |
   572  | `Insecure`       | boolean          | Set to `true` if the S3 service is available by `HTTP`. Set to `false` by default. |
   573  
   574  Example:
   575  
   576  ```toml
   577  [runners.cache]
   578    Type = "s3"
   579    Path = "path/to/prefix"
   580    Shared = false
   581    [runners.cache.s3]
   582      ServerAddress = "s3.amazonaws.com"
   583      AccessKey = "AMAZON_S3_ACCESS_KEY"
   584      SecretKey = "AMAZON_S3_SECRET_KEY"
   585      BucketName = "runners-cache"
   586      BucketLocation = "eu-west-1"
   587      Insecure = false
   588  ```
   589  
   590  NOTE: **Note:**
   591  For Amazon's S3 service, the `ServerAddress` should always be `s3.amazonaws.com`. The Minio S3 client will
   592  get bucket metadata and modify the URL to point to the valid region (eg. `s3-eu-west-1.amazonaws.com`) itself.
   593  
   594  NOTE: **Note:**
   595  If any of `ServerAddress`, `AccessKey` or `SecretKey` aren't specified, then the S3 client will use the
   596  IAM instance profile available to the `gitlab-runner` instance.
   597  
   598  ### The `[runners.cache.gcs]` section
   599  
   600  > Introduced in GitLab Runner 11.3.0.
   601  
   602  Configure native support for Google Cloud Storage. Read the
   603  [Google Cloud Storage Authentication documentation](https://cloud.google.com/storage/docs/authentication#service_accounts)
   604  to check where these values come from.
   605  
   606  | Parameter         | Type             | Description |
   607  |-------------------|------------------|-------------|
   608  | `CredentialsFile` | string           | Path to the Google JSON key file. Currently only the `service_account` type is supported. If configured, takes precedence over `AccessID` and `PrivateKey` configured directly in `config.toml`. |
   609  | `AccessID`        | string           | ID of GCP Service Account used to access the storage. |
   610  | `PrivateKey`      | string           | Private key used to sign GCS requests. |
   611  | `BucketName`      | string           | Name of the storage bucket where cache will be stored. |
   612  
   613  Examples:
   614  
   615  **Credentials configured directly in `config.toml` file:**
   616  
   617  ```toml
   618  [runners.cache]
   619    Type = "gcs"
   620    Path = "path/to/prefix"
   621    Shared = false
   622    [runners.cache.gcs]
   623      AccessID = "cache-access-account@test-project-123456.iam.gserviceaccount.com"
   624      PrivateKey = "-----BEGIN PRIVATE KEY-----\nXXXXXX\n-----END PRIVATE KEY-----\n"
   625      BucketName = "runners-cache"
   626  ```
   627  
   628  **Credentials in JSON file downloaded from GCP:**
   629  
   630  ```toml
   631  [runners.cache]
   632    Type = "gcs"
   633    Path = "path/to/prefix"
   634    Shared = false
   635    [runners.cache.gcs]
   636      CredentialsFile = "/etc/gitlab-runner/service-account.json"
   637      BucketName = "runners-cache"
   638  ```
   639  
   640  ## The `[runners.kubernetes]` section
   641  
   642  > Added in GitLab Runner v1.6.0
   643  
   644  This defines the Kubernetes parameters.
   645  See [Kubernetes executor](../executors/kubernetes.md) for additional parameters.
   646  
   647  | Parameter        | Type    | Description |
   648  |------------------|---------|-------------|
   649  | `host`           | string  | Optional Kubernetes master host URL (auto-discovery attempted if not specified) |
   650  | `cert_file`      | string  | Optional Kubernetes master auth certificate |
   651  | `key_file`       | string  | Optional Kubernetes master auth private key |
   652  | `ca_file`        | string  | Optional Kubernetes master auth ca certificate |
   653  | `image`          | string  | Default docker image to use for builds when none is specified |
   654  | `namespace`      | string  | Namespace to run Kubernetes jobs in |
   655  | `privileged`     | boolean | Run all containers with the privileged flag enabled |
   656  | `node_selector`  | table   | A `table` of `key=value` pairs of `string=string`. Setting this limits the creation of pods to kubernetes nodes matching all the `key=value` pairs |
   657  | `image_pull_secrets` | array | A list of secrets that are used to authenticate docker image pulling |
   658  
   659  Example:
   660  
   661  ```bash
   662  [runners.kubernetes]
   663  	host = "https://45.67.34.123:4892"
   664  	cert_file = "/etc/ssl/kubernetes/api.crt"
   665  	key_file = "/etc/ssl/kubernetes/api.key"
   666  	ca_file = "/etc/ssl/kubernetes/ca.crt"
   667  	image = "golang:1.8"
   668  	privileged = true
   669  	image_pull_secrets = ["docker-registry-credentials"]
   670  	[runners.kubernetes.node_selector]
   671  		gitlab = "true"
   672  ```
   673  
   674  ## Helper image
   675  
   676  When one of `docker`, `docker+machine` or `kubernetes` executors is used, GitLab Runner uses a specific container
   677  to handle Git, artifacts and cache operations. This container is created from a special image, named `helper image`.
   678  
   679  The helper image is based on Alpine Linux and it's provided for amd64 and arm architectures. It contains
   680  a `gitlab-runner-helper` binary which is a special compilation of GitLab Runner binary, that contains only a subset
   681  of available commands, as well as git, git-lfs, SSL certificates store and basic configuration of Alpine.
   682  
   683  When GitLab Runner is installed from the DEB/RPM packages, both images (`arm64` and `arm` based) are installed on the host.
   684  When the Runner prepares the environment for the job execution, if the image in specified version (based on Runner's git
   685  revision) is not found on Docker Engine, it is automatically loaded. It works like that for both
   686  `docker` and `docker+machine` executors.
   687  
   688  Things work a little different for the `kubernetes` executor or when GitLab Runner is installed manually. For manual
   689  installations, the `gitlab-runner-helper` binary is not included and for the `kubernetes` executor,the API of Kubernetes
   690  doesn't allow to load the `gitlab-runner-helper` image from a local archive. In both cases, GitLab Runner will download
   691  the helper image from Docker Hub, from GitLab's official repository `gitlab/gitlab-runner-helper` by using the Runner's
   692  revision and architecture for defining which tag should be downloaded.
   693  
   694  ### Overriding the helper image
   695  
   696  In some cases, you may need to override the helper image. There are many reasons for doing this:
   697  
   698  1. **To speed up jobs execution**: In environments with slower internet connection, downloading over and over again the
   699     same image from Docker Hub may generate a significant increase of a job's timings. Downloading the helper image from
   700     a local registry (where the exact copy of `gitlab/gitlab-runner-helper:XYZ` is stored) may speed things up.
   701  
   702  1. **Security concerns**: Many people don't like to download external dependencies that were not checked before. There
   703     might be a business rule to use only dependencies that were reviewed and stored in local repositories.
   704  
   705  1. **Build environments without internet access**: In some cases, jobs are being executed in an environment which has
   706     a dedicated, closed network (this doesn't apply to the `kubernetes` executor where the image still needs to be downloaded
   707     from an external registry that is available at least to the Kubernetes cluster).
   708  
   709  1. **Additional software**: Some users may want to install some additional software to the helper image, like
   710     `openssh` to support submodules accessible via `git+ssh` instead of `git+http`.
   711  
   712  In any of the cases described above, it's possible to configure a custom image using the `helper_image` configuration field,
   713  that is available for the `docker`, `docker+machine` and `kubernetes` executors:
   714  
   715  ```toml
   716  [[runners]]
   717    (...)
   718    executor = "docker"
   719    [runners.docker]
   720      (...)
   721      helper_image = "my.registry.local/gitlab/gitlab-runner-helper:tag"
   722  ```
   723  
   724  Note that the version of the helper image should be considered as strictly coupled with the version of GitLab Runner.
   725  As it was described above, one of the main reasons of providing such images is that Runner is using the
   726  `gitlab-runner-helper` binary, and this binary is compiled from part of GitLab Runner sources which is using an internal
   727  API that is expected to be the same in both binaries.
   728  
   729  The Runner by default references to a `gitlab/gitlab-runner-helper:XYZ` image, where `XYZ` is based
   730  on the Runner's architecture and git revision. Starting with **GitLab Runner 11.3** it's possible to define the version
   731  of used image automatically, by using one of the
   732  [version variables](https://gitlab.com/gitlab-org/gitlab-runner/blob/11-3-stable/common/version.go#L48-50):
   733  
   734  ```toml
   735  [[runners]]
   736    (...)
   737    executor = "docker"
   738    [runners.docker]
   739      (...)
   740      helper_image = "my.registry.local/gitlab/gitlab-runner-helper:x86_64-${CI_RUNNER_REVISION}"
   741  ```
   742  
   743  With that configuration, GitLab Runner will instruct the executor to use the image in version `x86_64-${CI_RUNNER_REVISION}`,
   744  which is based on its compilation data. After updating the Runner to a new version, this will ensure that the
   745  Runner will try to download the proper image. This of course means that the image should be uploaded to the registry
   746  before upgrading the Runner, otherwise the jobs will start failing with a "No such image" error.
   747  
   748  ## The `[runners.custom_build_dir]` section
   749  
   750  NOTE: **Note:**
   751  [Introduced](https://gitlab.com/gitlab-org/gitlab-runner/merge_requests/1267) in Gitlab Runner 11.10
   752  
   753  This section defines [custom build directories](https://docs.gitlab.com/ee/ci/yaml/README.html#custom-build-directories) parameters.
   754  
   755  Please notice, that the feature - if not configured explicitly - will be
   756  enabled by default for `kubernetes`, `docker`, `docker-ssh`, `docker+machine`
   757  and `docker-ssh+machine` executors. It will be disabled by default for all other
   758  executors.
   759  
   760  This feature requires that `GIT_CLONE_PATH` is within a path defined
   761  within `runners.builds_dir`. For the ease of using `builds_dir` the
   762  `$CI_BUILDS_DIR` variable can be used.
   763  
   764  The feature is by default enabled only for `docker` and `kubernetes` executors
   765  as they provide a good way to separate resources. This feature can be
   766  explicitly enabled for any executor, but special care should be taken when using
   767  with executors that share `builds_dir` and have `concurrent > 1`.
   768  
   769  | Parameter | Type    | Description |
   770  |-----------|---------|-------------|
   771  | `enabled` | boolean | Allow user to define a custom build directory for a job |
   772  
   773  Example:
   774  
   775  ```bash
   776  [runners.custom_build_dir]
   777    enabled = true
   778  ```
   779  
   780  ## Note
   781  
   782  If you'd like to deploy to multiple servers using GitLab CI, you can create a
   783  single script that deploys to multiple servers or you can create many scripts.
   784  It depends on what you'd like to do.
   785  
   786  [TOML]: https://github.com/toml-lang/toml
   787  [Docker Engine]: https://docs.docker.com/engine/
   788  [yaml-priv-reg]: https://docs.gitlab.com/ee/ci/yaml/README.html#image-and-services
   789  [ci-build-permissions-model]: https://docs.gitlab.com/ee/user/project/new_ci_build_permissions_model.html
   790  [secpull]: ../security/index.md#usage-of-private-docker-images-with-if-not-present-pull-policy
   791  
   792  [priv-example]: https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#define-an-image-from-a-private-container-registry
   793  [variable]: https://docs.gitlab.com/ee/ci/variables/#variables
   794  [cronvendor]: https://github.com/gorhill/cronexpr#implementation