Est.

Integrating Coding Agents With GitLab CI Pipelines

Agents need isolated jobs, clear triggers, and reviewable output to work inside GitLab CI.

· 9 min read
Cover illustration for “Integrating Coding Agents With GitLab CI Pipelines”
Agent Workflow Integration · October 21, 2026 · 9 min read · 1,950 words

To use coding agents in GitLab CI pipelines, teams need to give them isolated jobs, useful triggers, and output that engineers can review through their existing merge workflows. Replicas connects autonomous coding agents to Linear and Slack, so teams can send Claude Code or Codex tasks from tickets or messages to run in isolated computing environments. Whether work starts there or inside GitLab, the integration succeeds when agent output enters the same testing, review, and approval loop as human-written code.

Why wiring agents into GitLab CI is a different problem than using agents locally

A local agent can write code while leaving the developer responsible for every handoff that follows. The developer still has to get the code tested, ask for review, act on the findings, and move the change toward release. GitLab’s May 2026 tutorial makes this point directly: writing code and shipping software are different problems.

The pipeline already enforces code quality, runs security scans, and controls when code can be merged. An agent that participates in that loop can return work through those controls instead of leaving a developer to assemble the next steps. This requires triggers inside the workflow, a bounded execution environment, and reviewable results such as merge requests, inline comments, or structured reports. Closing that gap is a concrete integration problem, beginning with the surfaces GitLab exposes.

The three integration layers GitLab CI exposes to agents

GitLab exposes three integration layers, namely mention-driven automation, structured pipeline jobs, and MCP server connections. Mention-driven automation belongs to the Duo Agent Platform layer, where an engineer requests work in an issue or merge request comment. GitLab’s February 2026 demo shows Claude reading an issue, building a full-stack Java web application, and opening a merge request without anyone having to write YAML or work in a terminal. A mention can also request a review that covers strengths, critical issues, security concerns, and an approval recommendation.

Structured pipeline jobs serve a different purpose because they make a bounded task repeatable without a fresh human prompt. An agent can run on every MR to analyze code quality or generate fixes, returning JSON reports or patch files. MCP server connections supply context rather than a schedule, exposing GitLab issues, files, and pipelines to compatible agents. GitLab’s three-workflow tutorial contrasts assumptions drawn from local files with work grounded in the actual issue through MCP.

These layers separate the request, execution, and context needed for agent work. They also share the principle that work should begin where engineers already coordinate it. For example, Replicas accepts tasks from Slack, Linear, GitHub, GitLab, or its dashboard. A Slack message can start the work, while a Linear issue gives the agent the ticket context it needs to do it.

Configuring the pipeline job: environment, permissions, and output artifacts

The structured job is the point where the agent’s task becomes an execution contract. Its container should be isolated and non-privileged, with no host mounts, no access to fork-pipeline secrets, and an explicit tool allowlist. The environment must still permit the package installation and test execution needed to verify the requested work.

Credentials for .gitlab-ci.yml should be stored in CI/CD variables. On self-managed GitLab instances, enabling injectGatewayToken in the external agent configuration supplies AI_FLOW_AI_GATEWAY_TOKEN and AI_FLOW_AI_GATEWAY_HEADERS to the runtime. Credential handling also extends to output, since a comment can expose a secret just as a configuration file can. Upsun’s review agent redacts credentials before posting responses as MR comments.

Code quality findings should be written to gl-code-quality-report.json and declared as a codequality report within the job’s artifact reports configuration. GitLab can then surface them inline in the MR diff without additional tooling. Setting artifact paths and expiry times makes it easier to know how much storage the job will use across many MRs.

Raw agent logs require a separate parsing boundary. The documented marker-based pattern strips ANSI escape codes and extracts the JSON block between known delimiters for downstream steps. Instructions that apply to every job should go in a rules file at the repository root. Claude Code reads CLAUDE.md, while OpenAI’s Codex documentation names AGENTS.md as the main file for project instructions.

Trigger points that make agents useful at MR scale

Automatic MR triggers aim to place findings in front of reviewers before they make a merge decision. Opening an MR, pushing to its branch, or rebasing it can initiate review work. Upsun’s production review agent responds to these events through webhooks. Its earlier version ran as a manual CI job, so reviewers could ask for analysis when they needed it without paying for a review on every commit.

Mentions work well when a request needs context from a person, such as which feedback to address, which failing test to explain, or which missing pipeline to generate. GitLab’s mention-driven demos show how this works for code generation and review. Upsun sorts requests as they come in, using Claude Haiku to answer simple questions and sending complex tasks to Opus through the CI pipeline. This keeps a short question from automatically receiving the same treatment as a deep review.

Security remediation has a more precise trigger because the relevant context arrives after a scan. GitLab’s April 2026 release of GitLab 18.11 made Agentic SAST Vulnerability Resolution generally available for Ultimate customers. The agent analyzes confirmed true positives, generates a root-cause fix, and opens a ready-to-review MR with a confidence score. Triggering here scopes work to actual findings rather than speculative vulnerabilities and gives developers a linked patch to review.

An incremental reviewer compares the change with its previous review state, reports what changed, and resolves its own threads when the author fixes an issue. Upsun’s webhook-driven service maintains that state outside the pipeline. A YAML-only job needs an external store to do the same, making state persistence an architectural requirement.

What agents can and cannot do autonomously in the CI loop today

The useful capability boundary separates producing a reviewable result from controlling the whole delivery process. Agents can examine a diff, explain security concerns, recommend approval, and write native code quality reports. GitLab’s CI Expert Agent can inspect a repository, identify its language and framework, and ask guided questions to generate a CI/CD configuration. That feature was in beta as of GitLab 18.11, while SAST fix generation was generally available for Ultimate customers.

Interaction also differs by integration path. As of April 2026, the @codex mention workflow ran asynchronously in the background without interactive steering during the task. A new Git commit pushed by the agent automatically triggered downstream pipelines, but that did not make the running task conversational. This distinction matters when a request needs clarification during execution.

Context and access introduce separate constraints. A diff-only agent lacks the surrounding codebase and issue context that MCP can provide. GitLab makes MCP server access available on Free, Premium, and Ultimate, while connecting Claude Code or Codex through External Agents requires Premium or Ultimate. SAST Vulnerability Resolution and the Security Analyst Agent require Ultimate. Exact latency and token limits for Duo-triggered sessions are not publicly documented, so the available capability descriptions do not establish a timing or consumption budget.

Which should teams choose between Claude Code, Codex, and Cursor for CI pipeline jobs

Claude Code works well for headless CI jobs that need code review, analysis, or reasoning about the architecture. It reads project rules from CLAUDE.md, and GitLab uses Claude as its reference external agent for generation, review, and pipeline creation. Upsun’s production implementation uses the Claude Agent SDK, with Haiku handling classification and Opus handling deeper review.

Codex fits structured, non-interactive jobs with a well-defined task and predictable output. The documented codex exec pattern invokes it as a CI step that produces structured JSON for GitLab’s artifact system. Its documented execution model separates dependency setup from task execution, with network access during setup and no internet access by default during execution.

Cursor’s IDE-bound agent mode is less suited to unattended pipeline jobs. It serves interactive feature development locally, but Claude Code or Codex is the better fit for the headless jobs described here. A team can therefore keep Cursor in its local workflow without making it the pipeline harness. Local editor choice and CI execution choice do not have to be identical.

A harness-agnostic execution layer is another option when teams do not want the integration coupled to one agent. Replicas provides that layer through model-agnostic execution and per-run attribution covering source, harness, model, credential, and runtime. Its role differs from the harness itself, providing the environment in which the selected agent works and returns reviewable output. The architectural choice is therefore not only which agent to run, but which execution responsibilities to keep independent of it.

Environment configuration that lets agents do reliable work in CI

A shared environment can carry installed packages or leftover state from one run into another, undermining repeatability. Giving each run its own non-privileged environment keeps it from affecting other runs. At the infrastructure layer, microVM-backed environments using technologies such as Kata Containers with Cloud Hypervisor or Firecracker give each execution its own kernel.

The next concern is whether the environment can perform the work the prompt requests. Dependencies and tooling should be pre-loaded so the agent does not rebuild its development environment from scratch on every run. This cuts the work needed at startup and makes setup less dependent on the network being available. Isolated cloud computing environments, including those configured for Replicas tasks, combine that preparation with the ability to install dependencies, run databases, and verify changes. The result must be an environment for generating and testing code.

Repository context then needs explicit provisioning. Upsun’s review agent shows how access can grow from the git diff and commit log to related files and issue-tracker context. The rules file should set out the code style, what testing is expected, and the security constraints. Relevant requirements include a coverage floor, testing before proposing changes, no committed secrets, parameterized queries, and clear input-validation boundaries. These instructions make the project’s expectations available on every run.

Review and analysis agents should be read-only, with file write and edit tools blocked, as in Upsun’s review architecture. Generation agents need permission to create branches and use the MR API so they can open an MR. Granting those capabilities does not justify broader repository write permissions. This separation keeps an analysis job from acquiring the side effects of an implementation job.

Measuring what CI-integrated agents actually ship

More merges can coexist with more review time and more downstream rework. That is the measurement paradox of agent-augmented CI, where activity can rise without a corresponding increase in delivered value. Lines changed and MR volume do not reveal whether reviewers had to rewrite the output or whether it survived deployment. Teams should primarily measure how much agent-generated work reached production without rework, and how long that took.

Delivery measures should include lead time from issue to production and deployment frequency. To measure quality, teams should track change failure rate and code churn, which show whether generated changes caused incidents or were later revised or reverted. Leverage requires a different denominator, namely the real effort and cost needed to produce the result. Token charges and usage-based costs belong in that calculation because seat licenses alone understate CI-scale spending.

Those measures become attributable only when the underlying runs carry enough identity. Teams need usage broken down by the task, agent, harness, model, credential, and runtime involved. The analytics layer in Replicas records attribution down to source, harness, model, and credential for every minute an agent runs, providing data that can connect activity with delivery outcomes. The useful endpoint is not a count of agent jobs, but a traceable account of what shipped, what delayed review, and where rework changed the result.

More in Agent Workflow Integration