Text of code.claude.com › docs › en › gitlab-ci-cd as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Claude Code GitLab CI/CD - Claude Code Docs

Documentation Index Fetch the complete documentation index at: /docs/llms.txt Use this file to discover all available pages before exploring further. Skip to main content Assistant Responses are generated using AI and may contain mistakes. Claude Code for GitLab CI/CD is currently in beta. Features and functionality may evolve as we refine the experience. This integration is maintained by GitLab. For support, see the following GitLab issue .

This integration is built on top of the Claude Code CLI and Agent SDK , enabling programmatic use of Claude in your CI/CD jobs and custom automation workflows. Why use Claude Code with GitLab? Instant MR creation : Describe what you need, and Claude proposes a complete MR with changes and explanation Automated implementation : Turn issues into working code with a single command or mention Project-aware : Claude follows your CLAUDE.md guidelines and existing code patterns Simple setup : Add one job to .gitlab-ci.yml and a masked CI/CD variable Enterprise-ready : Choose Claude API, Amazon Bedrock, or Google Cloud’s Agent Platform to meet data residency and procurement needs Secure by default : Runs in your GitLab runners with your branch protection and approvals How it works Claude Code uses GitLab CI/CD to run AI tasks in isolated jobs and commit results back via MRs: Event-driven orchestration : GitLab listens for your chosen triggers (for example, a comment that mentions @claude in an issue, MR, or review thread).

The job collects context from the thread and repository, builds prompts from that input, and runs Claude Code. Provider abstraction : Use the provider that fits your environment: Claude API (SaaS) Amazon Bedrock (IAM-based access, cross-region options) Google Cloud’s Agent Platform (GCP-native, Workload Identity Federation) Sandboxed execution : Each interaction runs in a container with strict network and filesystem rules.

Claude Code enforces workspace-scoped permissions to constrain writes. Every change flows through an MR so reviewers see the diff and approvals still apply. Pick regional endpoints to reduce latency and meet data-sovereignty requirements while using existing cloud agreements. What can Claude do? In a GitLab pipeline, Claude Code can: Create and update MRs from issue descriptions or comments Analyze performance regressions and propose optimizations Implement features directly in a branch, then open an MR Fix bugs and regressions identified by tests or comments Respond to follow-up comments to iterate on requested changes Setup Quick setup The fastest way to get started is to add a minimal job to your .gitlab-ci.yml and set your API key as a masked variable.

Add a masked CI/CD variable Go to Settings → CI/CD → Variables Add ANTHROPIC_API_KEY (masked, protected as needed) Add a Claude job to .gitlab-ci.yml stages : - ai claude : stage : ai image : node:24-alpine3.21 # Adjust rules to fit how you want to trigger the job: # - manual runs # - merge request events # - web/API triggers when a comment contains '@claude' rules : - if : '$CI_PIPELINE_SOURCE == "web"' - if : '$CI_PIPELINE_SOURCE == "merge_request_event"' variables : GIT_STRATEGY : fetch before_script : - apk update - apk add --no-cache git curl bash - curl -fsSL https://claude.ai/install.sh | bash # The installer places claude in ~/.local/bin, which isn't on PATH in this image - export PATH="$HOME/.local/bin:$PATH" script : # Optional: start a GitLab MCP server if your setup provides one - /bin/gitlab-mcp-server || true # Use AI_FLOW_* variables when invoking via web/API triggers with context payloads - echo "$AI_FLOW_INPUT for $AI_FLOW_CONTEXT on $AI_FLOW_EVENT" - > claude -p "${AI_FLOW_INPUT:-'Review this MR and implement the requested changes'}" --permission-mode acceptEdits --allowedTools "Bash Read Edit Write mcp__gitlab" --debug After adding the job and your ANTHROPIC_API_KEY variable, test by running the job manually from CI/CD → Pipelines , or trigger it from an MR to let Claude propose updates in a branch and open an MR if needed.

To run on Amazon Bedrock or Google Cloud’s Agent Platform instead of the Claude API, see the Using with Amazon Bedrock and Google Cloud section below for authentication and environment setup. Manual setup (recommended for production) If you prefer a more controlled setup or need enterprise providers: Configure provider access : Claude API : Create and store ANTHROPIC_API_KEY as a masked CI/CD variable Amazon Bedrock : Configure GitLab → AWS OIDC and create an IAM role for Amazon Bedrock Google Cloud’s Agent Platform : Configure Workload Identity Federation for GitLab → GCP Add project credentials for GitLab API operations : Use CI_JOB_TOKEN by default, or create a Project Access Token with api scope Store as GITLAB_ACCESS_TOKEN (masked) if using a PAT Add the Claude job to .gitlab-ci.yml : use the Quick setup job for the Claude API, or a provider job from Configuration examples (Optional) Enable mention-driven triggers : Add a project webhook for “Comments (notes)” to your event listener (if you use one) Have the listener call the pipeline trigger API with variables like AI_FLOW_INPUT and AI_FLOW_CONTEXT when a comment contains @claude Example use cases Turn issues into MRs In an issue comment: @claude implement this feature based on the issue description Claude analyzes the issue and codebase, writes changes in a branch, and opens an MR for review.

Get implementation help In an MR discussion: @claude suggest a concrete approach to cache the results of this API call Claude proposes changes, adds code with appropriate caching, and updates the MR. Fix bugs quickly In an issue or MR comment: @claude fix the TypeError in the user dashboard component Claude locates the bug, implements a fix, and updates the branch or opens a new MR. Using with Amazon Bedrock and Google Cloud For enterprise environments, you can run Claude Code entirely on your cloud infrastructure with the same developer experience.

Amazon Bedrock Google Cloud's Agent Platform Prerequisites Before setting up Claude Code with Amazon Bedrock, you need: An AWS account with Amazon Bedrock access to the desired Claude models GitLab configured as an OIDC identity provider in AWS IAM An IAM role with Amazon Bedrock permissions and a trust policy restricted to your GitLab project/refs GitLab CI/CD variables for role assumption: AWS_ROLE_TO_ASSUME (role ARN) AWS_REGION (Amazon Bedrock region) Setup instructions Configure AWS to allow GitLab CI jobs to assume an IAM role via OIDC (no static keys).

Required setup: Enable Amazon Bedrock and request access to your target Claude models Create an IAM OIDC provider for GitLab if not already present Create an IAM role trusted by the GitLab OIDC provider, restricted to your project and protected refs Attach least-privilege permissions for Amazon Bedrock invoke APIs Use the Amazon Bedrock job example to exchange the job’s OIDC token for temporary AWS credentials at runtime.

Prerequisites Before setting up Claude Code with Google Cloud’s Agent Platform, you need: A Google Cloud project with: Google Cloud’s Agent Platform API enabled Workload Identity Federation configured to trust GitLab OIDC A dedicated service account with only the required Google Cloud’s Agent Platform roles GitLab CI/CD variables: GCP_WORKLOAD_IDENTITY_PROVIDER (provider resource name without the //iam.googleapis.com/ prefix, such as projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider ) GCP_SERVICE_ACCOUNT (service account email) GCP_PROJECT_ID (Google Cloud project ID) Setup instructions Configure Google Cloud to allow GitLab CI jobs to impersonate a service account via Workload Identity Federation.

Required setup: Enable IAM Credentials API, STS API, and Google Cloud’s Agent Platform API Create a Workload Identity Pool and provider for GitLab OIDC Create a dedicated service account with Google Cloud’s Agent Platform roles Grant the WIF principal permission t

The rest of this page is on the live site.