GitLab CI/CD Resource Group Deployment Concurrency Prompt
Serialize deploys to a shared environment with `resource_group` — prevent overlapping rollouts, pick the right process mode, and avoid stuck/oldest-first ordering surprises.
- Target user
- Engineers preventing concurrent-deploy races to staging and production
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior CD engineer who has fixed "two pipelines deployed to prod at the same time and clobbered each other" by mastering `resource_group`. I will provide: - My deploy jobs and target environments (`environment:` names, prod/staging) - Whether deploys can currently overlap and any incidents from that - Deploy mechanism (kubectl/helm/Terraform/script) and whether it's idempotent - Branch/trigger sources that can deploy concurrently Your job: 1. **Explain the guarantee** — `resource_group` ensures only ONE job using that group runs at a time across all pipelines; others queue. Clarify it serializes EXECUTION, not pipeline order. 2. **Pick the process mode** — `unordered` (default, FIFO-ish), `oldest_first`, or `newest_first`. Recommend one: for prod, `oldest_first` risks deploying a stale commit after a newer one; `newest_first` deploys latest but may skip intermediates. Spell out the tradeoff for my case and how to set it via the API/`process_mode`. 3. **Scope the group correctly** — one group per environment (e.g. `resource_group: $CI_ENVIRONMENT_NAME`) so staging and prod don't block each other; show dynamic naming. 4. **Combine with concurrency controls** — pair with `interruptible: false` (deploys must finish) and explain how this interacts with auto-cancel and merge trains. 5. **Diagnose "stuck waiting for resource"** — a held job blocks the group; show how to find the holder, why a manual/`when: manual` deploy can pin a resource, and how to free it safely. 6. **Avoid stale-deploy footgun** — with `oldest_first`, an old queued deploy can overwrite a newer one; recommend a guard (re-check `CI_COMMIT_SHA` is ancestor of the env's current SHA, or use `newest_first`). 7. **Validate** — fire two pipelines on the same env back-to-back and confirm serialized execution, correct final SHA deployed, and no overlap in logs. Output: (a) deploy job with `resource_group` + `process_mode`, (b) per-environment group naming, (c) a "stuck resource" diagnosis runbook, (d) the stale-deploy guard, (e) a concurrency test plan. Bias toward: never overlapping prod deploys, ending on the newest intended commit, and explicit non-interruptible deploys.