What is a build agent or runner?
BeginnerConceptCI/CD practices
Answer
In one line: A build agent (Jenkins calls it an agent, GitHub and GitLab call it a runner) is the machine or container that actually executes your pipeline jobs, while the CI server only schedules and coordinates them.
How it works:
- The CI server (Jenkins controller, GitHub, GitLab) receives a trigger, such as a push.
- It picks an available agent that matches the job's requirements (labels, OS, tools).
- The agent checks out the code, runs the steps (build, test, docker build) and sends logs and results back.
Types of agents:
- Hosted / cloud runners — provided by the CI service (for example GitHub-hosted
ubuntu-latest). No maintenance, but less control and you pay per minute after free limits. - Self-hosted runners — your own VMs or servers. More control, access to private networks, custom tools, but you must patch, secure and scale them.
- Ephemeral container/Kubernetes agents — a fresh pod is created for each job and deleted afterwards (Jenkins Kubernetes plugin, GitLab Kubernetes executor, Actions Runner Controller). Clean, scalable and cost-efficient.
Good practices:
- Prefer ephemeral agents — every job starts clean, so leftovers from one build can't break or poison another.
- Don't run builds on the Jenkins controller — keep it for scheduling only.
- Use labels to route jobs to the right agents (for example
linux-docker,windows,gpu). - Secure them — agents have access to secrets and code. Use least privilege, isolate them, and be very careful with self-hosted runners on public repositories (anyone could submit a PR that runs code on your machine).
- Autoscale — scale agents up during busy hours and down at night to save money.
Example: a team runs GitHub Actions self-hosted runners on EKS with Actions Runner Controller. Each job gets a fresh pod that can reach the private ECR registry and internal test databases, and the pod is destroyed when the job ends.
Tip for interviews: mention ephemeral agents and the security risk of self-hosted runners on public repos — both are common follow-up topics.
More on CI/CD practices
What is "pipeline as code", and why is it better than configuring pipelines in a UI?BeginnerWhat are pipeline triggers?BeginnerWhat is a quality gate in a CI/CD pipeline?BeginnerHow do you make a slow CI/CD pipeline faster?BeginnerWhat are secrets in CI/CD, and how should they be handled?BeginnerWhat is a monorepo vs a polyrepo, and how does it affect CI/CD?Beginner