Skip to content

Add custom executor

Kamil Trzciński requested to merge add-generic-executor into master

What does this MR do?

Supersedes !1115 (diffs).

Create a new executor called custom to allow users to create their own executors as described in #2885 (closed).

Below is a sample of the configuration:

[[runners]]
  name = "custom"
  url = "https://gitlab.com"
  token = "TOKEN"
  executor = "custom"
  builds_dir = "/builds"
  cache_dir = "/cache"
  [runners.custom]
    config_exec = "/path/to/config.sh"
    config_args = [ "SomeArg" ]
    config_exec_timeout = 200

    prepare_exec = "/path/to/script.sh"
    prepare_args = [ "SomeArg" ]
    prepare_exec_timeout = 200

    run_exec = "/path/to/binary"
    run_args = [ "SomeArg" ]

    cleanup_exec = "/path/to/executable"
    cleanup_args = [ "SomeArg" ]
    cleanup_exec_timeout = 200

    graceful_kill_timeout = 200
    force_kill_timeout = 200

This follows the following format:

  1. Creates a temp directory in which each script is executed in,
  2. Sets all GitLab Runner variables marked as internal or public as CUSTOM_ENV_, as they can be read by the script itself, like CUSTOM_ENV_CI_ID,
  3. Executes prepare_script and cleanup_script with any arguments that are passed to prepare_args & cleanup_args
  4. Executes run_exec /path/to/script.with_extension stage_name.

It implements a deadline and kills:

  1. Sends SIGTERM to script if one of the deadlines from configuration is met.
  2. Send SIGKILL if the graceful_kill_timeout deadline is met.
  3. The run_exec can run timeout defined by project or runner, and is subject to job abort.

Adding support for Terminal would be exposing additional script that would run concurrently: terminal_script.

Documentation for this executor was added in a separate MR: !1416 (merged)

Next items

Expose for run_script information about all job configurations: image:, services:, etc. This should be per-run_script instead of prepare_script or cleanup_script.

Likely the format would be:

CUSTOM_ENV_OPTIONS_IMAGE=ruby:2.1
CUSTOM_ENV_OPTIONS_SERVICES_0_IMAGE=mysql:1.0
...

Two follow up issues are created for this:

Why was this MR needed?

Implement: #2885 (closed).

Does this MR meet the acceptance criteria?

  • Documentation created/updated
  • Added tests for this feature/bug
  • In case of conflicts with master - branch was rebased

What are the relevant issue numbers?

closes #2885 (closed)

Documentation at: !1416 (merged)

Edited by Steve Xuereb

Merge request reports