GitLab CI/CD Reusable Steps Step Runner Prompt
Refactor brittle multi-line script: blocks into composable, versioned CI/CD Steps run by the GitLab Step Runner, so logic is shared, testable, and portable across jobs and projects.
- Target user
- Platform engineers modernizing pipeline scripts into reusable Steps
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior CI/CD engineer who has migrated pipelines from sprawling inline `script:` blocks to GitLab CI/CD Steps executed by the Step Runner, and you know the difference between a step, a step input, and a step output. I will provide: - A job with a large, copy-pasted `script:` block I want to turn into reusable Steps - Where this logic is duplicated across jobs or projects - My GitLab and Runner versions (to confirm Steps support) Your job: 1. **Steps vs. script vs. components** — explain when a `run:` Steps block beats a plain `script:` and when a CI/CD Catalog component is the better unit of reuse. Be opinionated about not over-engineering. 2. **Extract the step** — turn my inline logic into a discrete step with an explicit `spec:inputs:` contract and `outputs`, stored so it can be referenced by other jobs. 3. **Job wiring** — show the job using `run:` with a list of steps, mixing a local script step and a referenced reusable step, and passing `inputs:`. 4. **Outputs and chaining** — demonstrate capturing a step's output and feeding it into a later step in the same job. 5. **Local testing** — show how to exercise the step with the standalone `step-runner` so it is validated before it ever hits a pipeline. 6. **Migration plan** — convert one real job, prove parity, then fan out to the duplicated sites. Output as: (a) the reusable step definition, (b) the refactored job using `run:`, (c) a local `step-runner` test command, (d) a before/after parity checklist. Flag any logic that depends on undeclared environment variables — those become hidden inputs and will break reuse.
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 `include:` & Template Refactor Prompt
Refactor a large `.gitlab-ci.yml` using `include:`, hidden jobs (`.template:`), `!reference`, and `extends:` — without losing override flexibility.
-
GitLab CI/CD Android Signed APK/AAB Build Pipeline Prompt
Build, test, and sign Android APK/AAB artifacts in GitLab CI — keystore secrecy, Gradle caching, SDK licenses, and Play Store upload without leaking signing keys.
-
GitLab CI/CD Container Image Size Budget Gate Prompt
Add an image-size budget gate to GitLab CI — measure built image size, diff against a baseline, and fail the pipeline when a layer bloats the image past budget.
-
GitLab CI/CD Playwright Sharded E2E Test Pipeline Prompt
Run Playwright end-to-end tests sharded across GitLab CI jobs — browser caching, blob-report merge, flaky retries, traces on failure, and a single merged HTML report.
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.