Запуск ИИ-агентов в TeamCity: экспериментальный плагин AI Agents для Codex и Claude Code
Источник: https://blog.jetbrains.com/teamcity/2026/11/run-ai-agents-in-teamcity/
Краткое содержание
Кодирующие агенты можно запускать не только на машине разработчика, но и в CI/CD: для ревью кода, расследования упавших сборок, обновления документации и других задач репозитория. Новый экспериментальный плагин AI Agents для TeamCity запускает Codex и Claude Code прямо в сборках и подключает их к выбранному провайдеру LLM. Плагин ставит агента на build agent TeamCity, безопасно выдаёт учётные данные на время сборки и собирает статистику использования и траектории агента.
Что делает плагин
Подключения к провайдерам хранятся как соединения TeamCity: поддерживаются JetBrains Air, OpenAI, Anthropic, LiteLLM и OpenRouter (шлюзы дают доступ к гораздо более широкому набору моделей). Предустановка Codex или Claude Code на каждом агенте не нужна: при старте сборки плагин проверяет наличие клиента и при необходимости ставит его, после чего codex или claude вызываются из обычного шага Command Line. Поскольку build agents часто переиспользуются, учётные данные провайдера выдаются только на время сборки и затем удаляются. Статистика токенов (prompt, completion, cached, total) публикуется как обычные статистические значения TeamCity, из них можно строить графики и замечать аномалии расходов. Траектории сохраняются в HTML (сообщения, вызовы инструментов, токены) и JSON (для программного анализа нескольких запусков); с локальным агентом и TeamCity CLI можно пакетно выгружать траектории и получить цикл обратной связи: запуск в CI, сбор траекторий, анализ, правка промпта.
Настройка
Плагин ставится с JetBrains Marketplace на сервер TeamCity. Шаг 1: в Project Settings | Connections создать соединение (для JetBrains Air нужны client ID и client secret сервисного аккаунта; у каждой команды может быть свой, что позволяет учитывать общие расходы). Шаг 2: в конфигурации сборки добавить build feature AI Agent, выбрать Codex или Claude Code и соединение. Шаг 3: добавить шаг Command Line с промптом.
codex exec --ephemeral --skip-git-repo-check "summarize this repository"
claude -p "summarize this repository"
После сборки телеметрия и траектории публикуются как скрытые артефакты в .teamcity/ai-agents/. Чтобы увидеть отчёт в результатах, в Project Settings | Report Tabs создаётся вкладка с начальной страницей .teamcity/ai-agents/trajectory.html и названием «AI Agent Trajectory».
Предостережение и статус
Артефакты могут содержать промпты, исходный код и ответы модели, поэтому доступ к ним нужно ограничивать как к другим чувствительным артефактам. Плагин экспериментальный, функциональность может меняться; обратная связь принимается в Slack-сообществе TeamCity.
Значимость
Шаг переводит агентов из локального инструмента в управляемый элемент CI с учётом токенов, изоляцией секретов и воспроизводимым анализом траекторий, что отвечает основным операционным проблемам агентной автоматизации. Статус эксперимента означает, что для продакшена пока рано.
🧾 Транскрипт (формат)
Run AI Agents in TeamCity Source: https://blog.jetbrains.com/teamcity/2026/11/run-ai-agents-in-teamcity/
AI coding agents don’t have to run only on a developer’s machine. You can also make them part of your CI/CD workflows to review code, investigate failed builds, update documentation, or handle other repository tasks.
The new experimental AI Agents plugin for TeamCity lets you run Codex and Claude Code directly in TeamCity builds and connect them to the LLM provider of your choice.
The plugin installs the coding agent on the TeamCity build agent, provides credentials safely for the duration of the build, and collects usage statistics and agent trajectories.
When a build starts, the plugin checks whether the selected client is available and installs it if necessary. You can then call codex or claude from a regular TeamCity Command Line build step.
Install the plugin
What does the AI Agents plugin do? The plugin handles much of the setup needed to run coding agents reliably in CI.
Connect to your preferred LLM provider The plugin stores your provider credentials as a TeamCity connection. It currently supports:
JetBrains Air OpenAI Anthropic LiteLLM OpenRouter This is not limited to models provided directly by these services. Gateways such as OpenRouter and LiteLLM give you access to a much wider range of models, so you can choose models and providers that make sense for your team.
Run Codex and Claude Code without preinstalling them You don’t have to install Codex or Claude Code manually on every TeamCity build agent. When a build starts, the plugin checks whether the selected client is available and installs it if necessary. You can then call codex or claude from a regular TeamCity Command Line build step.
Keep provider credentials out of your build agents TeamCity build agents are often reused across builds, so leaving provider credentials on an agent can be a security risk. The plugin provides the necessary credentials to the TeamCity agent only for the duration of the build and removes them afterward.
Your provider credentials are managed through the TeamCity connection rather than permanently stored on individual build agents.
Track token usage The plugin collects usage statistics from agent runs and publishes them as TeamCity statistical values, including prompt, completion, cached, and total token counts.
Because these are regular TeamCity statistics, you can use them to track AI usage over time and create charts. This can also help you spot unexpected changes in token consumption and investigate possible cost anomalies.
Inspect and analyze agent trajectories When an AI agent does something unexpected, seeing its final response is often not enough. You need to understand what happened along the way.
The plugin records the agent trajectory and makes it available in two formats:
HTML gives you a readable view of the agent’s messages, tool calls, and token usage. JSON makes trajectories available for programmatic analysis. The JSON format is especially useful when you want to analyze multiple agent runs together, like to understand why an agent behaves a certain way or how to adjust the original prompt to get better results.
You can also use a local coding agent together with the TeamCity CLI to retrieve trajectories from multiple builds and analyze them in batches. This gives you a practical feedback loop: run an agent in CI, collect its trajectories, analyze what happened across multiple runs, adjust the prompt, and try again.
This makes trajectories useful both for debugging individual builds and improving the agent workflows you run in CI.
Set up the plugin Install the plugin from JetBrains Marketplace and add it to your TeamCity server.
1. Create a connection First, you need to set up a connection. The plugin supports various LLM providers and gateways. Open Project Settings | Connections.
Supported providers:
OpenAI Anthropic OpenRouter LiteLLM JetBrains Air Enter the credentials required for your connection and save it.
If you’re using JetBrains Air, enter your service account client ID and client secret. Each team can use its own service account, which makes it possible to track shared AI usage and spending.
2. Add the AI Agent build feature Open the build configuration where you want to use the coding agent and add the AI Agent build feature.
Select Codex or Claude Code, then select the provider connection.
3. Add your prompt Add a Command Line build step and call codex or claude as usual.
With Codex:
codex exec --ephemeral --skip-git-repo-check "summarize this repository"
With Claude Code:
claude -p "summarize this repository"
The plugin finds or installs the selected client and prepares its configuration for the build. You can replace these example prompts with whatever task you want the agent to perform as part of your build.
Review what the agent did After the build finishes, the plugin publishes telemetry and agent trajectory files as hidden build artifacts under: .teamcity/ai-agents/.
It also publishes statistical values, such as prompt, completion, cached, and total token counts.
For a more convenient view, the plugin generates an HTML report showing the agent’s messages, tool calls, and token usage.
You can make this report available directly from the TeamCity build results.
Go to Project Settings | Report Tabs, create a build report tab, and use: .teamcity/ai-agents/trajectory.html as the start page and “AI Agent Trajectory” as the name. This gives you a tab where you can inspect what the agent did during the build.
A note about sensitive data The generated artifacts may contain prompts, source code, and model output. Treat them the same way you would other sensitive build artifacts and make sure access is appropriately restricted.
Try the plugin The plugin is currently experimental, and its functionality may change as we continue developing it.
You can install it from JetBrains Marketplace and try running Codex or Claude Code in your TeamCity builds.
Install the plugin
We’d love to hear how you’re using it and what you’d like us to improve. Share your feedback in the TeamCity Slack community.