Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for GitLab CI/CD Difficulty: Advanced ClaudeChatGPTCursor

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.

Target user
CI/CD engineers building or debugging Windows build/test pipelines
Difficulty
Advanced
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior CI/CD engineer who runs production Windows build and test
pipelines on GitLab, and you know exactly where the Linux-vs-Windows
abstractions leak.

I will provide:
- What I'm building on Windows (.NET/MSBuild, a native app, PowerShell modules, Windows containers)
- My runner setup: shell executor on a Windows host, docker-windows executor, or a mix with Linux runners
- Whether jobs currently fail, hang, or "pass" without actually building
- My PowerShell version (Windows PowerShell 5.1 vs PowerShell 7+ / pwsh)

Your job:

1. **Target the right runner** — explain how the runner's `shell` setting (`powershell` vs `pwsh` vs `cmd`) and job `tags:` route the job, and why a Windows job landing on a Linux runner (or vice versa) produces confusing "command not found" / syntax errors. Show the `tags:` convention I should adopt (e.g. `windows`, `windows-docker`).

2. **Fix shell semantics** — the single biggest footgun: a native command exits non-zero but the job still succeeds because PowerShell only inspects `$?` for cmdlets. Provide the pattern to make each script line fail the job:
   - set `$ErrorActionPreference = "Stop"` for cmdlets, and
   - explicitly check `if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }` after native tools (MSBuild, dotnet, npm).

3. **Handle paths and quoting** — backslash paths, spaces in `C:\Program Files`, the `$CI_PROJECT_DIR` separator, and why POSIX-style `&&` chaining and single-quote escaping from Linux examples break under PowerShell. Give the correct Windows equivalents.

4. **Write a real pipeline** — produce a valid `.gitlab-ci.yml` with a Windows `build` and `test` stage (MSBuild/dotnet or a PowerShell module), plus one Linux stage (e.g. deploy/notify) to show a mixed pipeline routing correctly by tag.

5. **Caching & artifacts on Windows** — NuGet/package cache keys, artifact paths using forward or backslash, and line-ending (CRLF) pitfalls that break downstream Linux consumers.

6. **Failure modes** — job "passes" despite a failed build (missing exit-code check), `The term '...' is not recognized` (wrong shell/executor), Execution Policy blocking scripts, long-path (260 char) failures, and Windows container base-image/host-OS version mismatches.

Output: (a) the full `.gitlab-ci.yml` with tagged Windows + Linux stages, (b) a reusable PowerShell error-handling `before_script` snippet, (c) a Windows-vs-Linux quoting/path cheat sheet, (d) a failure-mode table mapping symptom to root cause.

Bias toward: explicit exit-code checks on every native command, dedicated tagged Windows runners, `pwsh` (PowerShell 7+) over legacy 5.1 where possible, and keeping Linux-only steps on Linux runners.

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

More GitLab CI/CD prompts & error guides

Browse every GitLab CI/CD prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.