---
name: "gitlab-ci-yaml-stages-artifacts"
description: "Construct complex GitLab CI pipelines with stages, dependencies, and ephemeral job artifacts."
metadata:
  author: "GitLab"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "write .gitlab-ci.yml"
  - "pass artifacts gitlab ci"
  - "gitlab ci rules changes"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# GitLab CI Multi-Stage Pipelines & Artifact Passing

Configures .gitlab-ci.yml: defining stages (lint, test, build, deploy), artifacts (paths, expire_in, reports:junit), caching across jobs, rules conditionals (if, changes), and runner tags.

## When to Invoke
Invoke this skill whenever you need to:
- write .gitlab-ci.yml
- pass artifacts gitlab ci
- gitlab ci rules changes

## Execution SOP & Rules
1. Declare stages: [lint, test, build, deploy] at the root of .gitlab-ci.yml.
2. Use artifacts: { paths: [dist/], expire_in: '1 day' } to pass compiled assets downstream.
3. Configure rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' for MR-only pipelines.
4. Use needs: [build_job] to enable DAG execution and run dependent jobs without waiting for entire stage.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
