Skip to content
CloudOps
Newsletter
All prompts
AI for GitLab CI/CD Difficulty: Advanced ClaudeChatGPT

GitLab Runner Custom Executor Driver Config Prompt

Build and debug a GitLab Runner Custom executor driver (config/prepare/run/cleanup scripts) to run jobs on an environment GitLab does not natively support — such as bespoke VMs, a hypervisor, or an isolated sandbox.

Target user
Runner administrators integrating non-standard job execution backends
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior Runner administrator who has authored GitLab Runner Custom executor drivers and knows the exact contract of the config, prepare, run, and cleanup stages.

I will provide:
- The execution backend I need (e.g. a custom VM manager, a remote sandbox, a hypervisor API)
- My current `config.toml` and what I have tried so far
- The failure I see (job hangs in prepare, run stage exits non-zero, cleanup leaks resources)

Your job:

1. **Executor contract** — explain the Custom executor lifecycle: `config_exec` (returns JSON to override settings), `prepare_exec`, `run_exec` (called once per script stage with a stage name), `cleanup_exec`, and which env vars (`CUSTOM_ENV_*`) each stage receives.

2. **config.toml** — produce a `[runners.custom]` block wiring my four scripts with sane `prepare_exec_timeout`, `cleanup_exec_timeout`, and `graceful_kill_timeout`.

3. **Driver scripts** — write skeletons for prepare/run/cleanup that provision the backend, execute the per-stage script GitLab passes on stdin, and tear down idempotently.

4. **Diagnose my failure** — map my symptom to a lifecycle stage and the likely cause (build-failure vs. system-failure exit codes matter).

5. **Build-failure vs. system-failure** — explain `BUILD_FAILURE_EXIT_CODE` and `SYSTEM_FAILURE_EXIT_CODE` and how returning the wrong one breaks retries and metrics.

6. **Cleanup guarantees** — ensure cleanup runs even when prepare or run aborts, so backends are never orphaned.

Output as: (a) the `config.toml` custom block, (b) prepare/run/cleanup script skeletons, (c) a stage-to-symptom diagnosis table, (d) an idempotent-cleanup checklist.

Do not assume the run stage is called once; it is invoked per script stage and your driver must be re-entrant.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week