On her first day with a build server, a new colleague asked why her change was "waiting for an agent" and whether she had broken something. She had not. She had simply met a word nobody had explained. This TeamCity starter glossary walks through agents, builds and chains in the order you are likely to bump into them, with a small story to hang each idea on. TeamCity is a continuous integration and delivery server from JetBrains. Screens and options differ between versions, so keep the official documentation nearby.
The story we will follow
Imagine a modest web shop. It has a service written by one pair of developers and a web front end written by another. Every time someone pushes code, they want it compiled, tested, packaged and eventually placed on a test environment. Nobody wants to do that by hand, and nobody wants to rely on whichever laptop happens to work. This imaginary shop is our practice ground.
Server and agents
The server is the coordinator. It stores configuration and history, watches repositories, decides what should run and shows you the results.
An agent is the worker. It is a separate program, usually on another machine or container, that receives a job from the server and executes it. If the server is the person taking orders at a counter, agents are the cooks. More cooks let more dishes be prepared at once, within the limits of your licence and hardware.
Our shop might begin with two agents. One has the Java tools needed by the service. The other has Node.js for the front end.
Projects and build configurations
A project is a folder with settings. It groups related work and can contain subprojects. The shop could have one project called Web Shop, holding the service and the front end.
A build configuration is a recipe: which repository to read, which steps to run, what starts it and which files to keep. A build is one execution of that recipe. People often blur the two in conversation. "The build is broken" usually means the latest run of a particular configuration failed.
VCS roots, steps and triggers
A VCS root describes how to reach a version control repository, including the address, branch settings and authentication.
Build steps are the actions performed in order, such as running a Maven or Gradle task, a command line script or a Docker command. A trigger decides when to start. The common one reacts to new commits. Others run on a schedule or after another build finishes.
When our developers push a change, the trigger adds a build to the queue, an agent picks it up and the steps run.
The queue and agent requirements
This is where our new colleague was stuck. A build waits in the queue until a suitable agent is free. Suitability depends on parameters and requirements. An agent reports facts about itself, such as its operating system and installed tools. A build configuration can require certain facts. If no connected agent matches, the build cannot start, and TeamCity can show you which requirements are unmet. If matching agents exist but are busy, patience or extra capacity is the answer.
Parameters
Parameters are named values that settings and scripts can use. Some are configuration parameters, some become environment variables and some are system properties passed to build tools. Define shared values high in the project tree and override them lower down only when necessary. For passwords and tokens, use the password parameter type or an external secrets integration, and remember that masking in logs is not a substitute for limiting who can edit builds.
Templates
Suppose the shop adds three more services that build the same way. Copying settings by hand invites drift. A build template holds the shared recipe, and configurations attached to it inherit changes while supplying their own values. One fix in the template then reaches them all, which is convenient and also a reason to test template edits carefully.
Artifacts
Artifacts are files kept from a build, such as a packaged application or a test report. You declare paths, and TeamCity stores the matching files with that run. Keep what you will deploy or investigate, and set clean-up rules so storage does not fill with forgotten copies.
Dependencies and build chains
An artifact dependency lets one build download files produced by another. A snapshot dependency says that a build relies on another build made from a consistent set of source revisions, and it fixes the order of execution.
A build chain is the linked set of builds formed by snapshot dependencies. In our shop it might look like this.
- Compile and unit test the service.
- Build the front end, which can run alongside it.
- Package both after they succeed.
- Deploy that package to the test environment and run checks.
If you start the last one, TeamCity works out what must happen first. It can reuse earlier successful results when nothing relevant has changed, according to the dependency settings. Using the packaged files from the same chain means the deployment receives what was actually tested.
Build status and the build log
Every run ends in a state, and the overview page shows it at a glance. A red result may come from a failing test, a step that exited with an error or a failure condition that someone configured, such as a run exceeding its time limit. The log is the diary of the run. Start near the first reported problem instead of the final line, since later errors are often only echoes of the earlier one.
In our shop, a developer once read the last message, blamed the packaging step and lost an hour. The real cause, a test that could not reach its database, sat much higher up. Collapsible log blocks make that kind of hunt quicker.
Branches and pull requests
A branch specification in the VCS root tells TeamCity which branches to watch beyond the default one. Builds are then labelled by branch, so a feature experiment is not confused with the main line. Pull request support can run checks and report results back to the hosting service when configured. Be cautious with contributions from outside your trusted group, because a build executes their code on your agents.
Personal builds, investigations and flaky tests
A personal build checks your changes without committing them to the shared branch first, where your tooling supports it. An investigation assigns a person to a failure, so the team knows someone is looking. A flaky test passes and fails without a related code change. Track it and repair it; muting hides the noise but leaves the doubt.
Configuration as code
Settings can be stored in version control using the Kotlin DSL or XML-based versioned settings. Changes then gain history and review. Agree early whether edits happen mainly in the browser or in code, because mixing habits without understanding synchronisation can confuse everyone.
Your first practice afternoon
Create a tiny project with one repository, one step that runs tests and one commit trigger. Make a test fail and read the log. Publish an artifact. Add a second configuration that consumes it, connect both with a snapshot dependency and run the chain. Then disconnect an agent in your practice setup and watch how the queue explains itself.
This blog's archive has the earlier Team City training details for background from that period. If a group wants guided learning around delivery pipelines, Cotocus lists CI/CD workshops among its services; you can open the Cotocus site and see its training options and ask whether TeamCity is included.
A week later, our new colleague saw "waiting for an agent" again. This time she opened the compatibility details, spotted a missing tool and told the team which machine needed it. The words had stopped being a wall.
Comments
Post a Comment