GitLab CI/CD Scheduled Pipelines & Nightly Jobs Prompt
Design scheduled pipelines for nightly builds, cron jobs, and periodic maintenance — gate jobs on `$CI_PIPELINE_SOURCE == 'schedule'`, pass schedule variables, and avoid duplicate-trigger waste.
- Target user
- Engineers building nightly E2E, dependency-update, and cleanup pipelines
- Difficulty
- Beginner
- Tools
- Claude, ChatGPT
The prompt
You are a senior CI engineer who runs reliable nightly and periodic GitLab pipelines that never accidentally fire on every push.
I will provide:
- What I want to run on a schedule (nightly E2E, dependency scans, cache warm, cleanup, reports)
- My current `.gitlab-ci.yml`
- The cadence (nightly, hourly, weekly) and target branch
- Whether some jobs should ONLY run on schedule and others always
Your job:
1. **Separate scheduled-only jobs from push jobs** — use `rules:` keyed on `$CI_PIPELINE_SOURCE == "schedule"` so nightly E2E doesn't run on every MR, and normal build/test doesn't re-run pointlessly at night. Show the exact `rules` for: schedule-only, push-only, and both.
2. **Set up the schedule** — explain the UI path (CI/CD → Schedules), the cron + timezone fields, the target branch, and that the schedule OWNER's permissions/protected-variable access apply (a footgun if they leave the project).
3. **Pass schedule variables** — define a variable on the schedule (e.g. `NIGHTLY=true`, `SUITE=full`) and branch on it in `rules`, so one `.gitlab-ci.yml` powers multiple schedules with different behavior.
4. **Prevent overlap & waste** — avoid two schedules colliding; use `resource_group` or `interruptible` where a long nightly could overlap the next run; skip if nothing changed where appropriate.
5. **Make failures visible** — schedules fail silently if nobody watches; wire a notification (Slack/email) on failed scheduled pipelines and surface the owning schedule name.
6. **Common pitfalls** — schedule disabled when owner loses access, cron timezone confusion (UTC vs local), schedule pointing at a stale/deleted branch, protected variables unavailable on non-protected target branch.
7. **Validate** — trigger the schedule manually ("Play"), confirm only the intended jobs ran via `CI_PIPELINE_SOURCE`, and confirm variables resolved.
Output: (a) the `rules:` blocks for schedule-only/push-only/both, (b) the schedule setup steps + variables, (c) overlap/notification handling, (d) a pitfalls checklist, (e) a manual-trigger validation step.
Bias toward: explicit `CI_PIPELINE_SOURCE` gating, visible failures, and a schedule owner that won't vanish.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
GitLab CI/CD Self-Hosted Renovate Dependency Bot Prompt
Run self-hosted Renovate as a scheduled GitLab pipeline that opens and auto-updates dependency MRs across your projects, with grouping, auto-merge on green pipelines, and a bounded MR/hour rate so you get controlled, reviewable dependency updates instead of a manual upgrade backlog.
-
GitLab CI/CD k6 Load Test Performance Gate Prompt
Design a .gitlab-ci.yml stage that runs k6 load/performance tests against a review or staging environment, enforces threshold-based pass/fail gates, and surfaces results as artifacts and metrics reports in merge requests.
-
GitLab CI/CD Publish to the Package Registry (npm, Maven, generic) Prompt
Design .gitlab-ci.yml jobs that build and publish versioned artifacts to the project or group Package Registry using CI_JOB_TOKEN auth, with proper version gating, immutability, and consumer install config.
-
GitLab CI/CD Windows Runner & PowerShell Pipeline Prompt
Design .gitlab-ci.yml pipelines that run on Windows runners (shell or docker-windows executor) with correct PowerShell shell handling, tag targeting, path/quoting fixes, and mixed Linux/Windows stages.
More GitLab CI/CD prompts & error guides
Browse every GitLab CI/CD prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.