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

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.
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