GitLab CI/CD Integration
Run Claude Code inside GitLab pipelines (beta, maintained by GitLab). Same idea as GitHub Actions: @claude mentions and pipeline triggers turn issues/comments into MRs.
What It Can Do
Section titled “What It Can Do”- Turn an issue into a working MR:
@claude implement this feature based on the issue description - Iterate on review feedback:
@claude suggest a concrete approach to cache this API call - Fix bugs from comments:
@claude fix the TypeError in the user dashboard component - Runs in your runners; every change flows through a normal MR with your branch protection and approvals
Minimal Setup
Section titled “Minimal Setup”- Settings → CI/CD → Variables: add
ANTHROPIC_API_KEY(masked) - Add a job to
.gitlab-ci.yml:
stages: [ai]
claude: stage: ai image: node:24-alpine3.21 rules: - if: '$CI_PIPELINE_SOURCE == "web"' - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' variables: GIT_STRATEGY: fetch before_script: - apk add --no-cache git curl bash - curl -fsSL https://claude.ai/install.sh | bash script: - > claude -p "${AI_FLOW_INPUT:-'Review this MR and implement the requested changes'}" --permission-mode acceptEdits --allowedTools "Bash Read Edit Write mcp__gitlab"- Optional
@claudemention triggers: add a “Comments (notes)” webhook that calls the pipeline trigger API withAI_FLOW_INPUT/AI_FLOW_CONTEXTvariables.
Enterprise Providers
Section titled “Enterprise Providers”Instead of an API key, authenticate via OIDC (no stored keys):
- Amazon Bedrock: GitLab OIDC → IAM role (
AWS_ROLE_TO_ASSUME,AWS_REGION) - Google Cloud Agent Platform: Workload Identity Federation (
GCP_WORKLOAD_IDENTITY_PROVIDER,GCP_SERVICE_ACCOUNT,CLOUD_ML_REGION)
Best Practices
Section titled “Best Practices”CLAUDE.mdat repo root — Claude follows it in CI too- Never commit keys; masked variables + OIDC where possible
- Set
max_turns/ job timeouts to bound cost; review Claude’s MRs like any contributor - Specific
@claudecommands = fewer iterations = lower token cost
Compare: 35-github-actions.md — same concept, GitHub-native tooling and official Anthropic support.
🧠 Quick Recall
Section titled “🧠 Quick Recall”- Trick: “GitHub Actions’ sibling: one job + one masked variable.”
👨🏫 Teach It
Section titled “👨🏫 Teach It”- Do: walk the minimal
.gitlab-ci.ymlline by line. - They’ll trip on: keys in the repo — masked CI/CD variables or OIDC, always.
Learning path: ⬅ 46-jetbrains-and-terminal-setup.md · Index · ➡ 48-computer-use.md
Written by Fenil Patel