Installing Buildkite Agent on Ubuntu

The Buildkite Agent is supported on Ubuntu versions 18.04 and above using our signed apt repository.

Installation

First, add our signed apt repository. The default version of the agent is stable, but you can get the beta version by using unstable instead of stable in the following command, or the agent built from the main branch of the repository by using experimental instead of stable.

echo "deb https://apt.buildkite.com/buildkite-agent stable main" | sudo tee /etc/apt/sources.list.d/buildkite-agent.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 32A37959C2FA5C3C99EFBC32A79206696452D198

Then install the agent:

sudo apt-get update && sudo apt-get install -y buildkite-agent

Configure your agent token:

sudo sed -i "s/xxx/INSERT-YOUR-AGENT-TOKEN-HERE/g" /etc/buildkite-agent/buildkite-agent.cfg

And then start the agent:

sudo systemctl enable buildkite-agent && sudo systemctl start buildkite-agent

You can view the logs at:

journalctl -f -u buildkite-agent

SSH Key Configuration

SSH keys should be copied to (or generated into) /var/lib/buildkite-agent/.ssh/. For example, to generate a new private key which you can add to your source code host:

$ sudo su buildkite-agent
$ mkdir -p ~/.ssh && cd ~/.ssh
$ ssh-keygen -t rsa -b 4096 -C "build@myorg.com"

See the Agent SSH Keys documentation for more details.

File Locations

  • Configuration: /etc/buildkite-agent/buildkite-agent.cfg
  • Agent Hooks: /etc/buildkite-agent/hooks/
  • Builds: /var/lib/buildkite-agent/builds/
  • Logs, depending on your system:
    • journalctl -f -u buildkite-agent (systemd)
    • /var/log/upstart/buildkite-agent.log (upstart)
    • /var/log/buildkite-agent.log (older systems)

  • Agent user home: /var/lib/buildkite-agent/
  • SSH keys: /var/lib/buildkite-agent/.ssh/

Configuration

The configuration file is located at /etc/buildkite-agent/buildkite-agent.cfg. See the configuration documentation for an explanation of each configuration setting.

Running multiple agents

You can run as many parallel agents on the one machine as you wish by duplicating the upstart service configuration file, for example:

# Disable the default unit
sudo systemctl stop buildkite-agent && sudo systemctl disable buildkite-agent

# Create a systemd template
sudo cp /lib/systemd/system/buildkite-agent.service /etc/systemd/system/buildkite-agent@.service

# Now, as many times as you like
sudo systemctl enable --now buildkite-agent@1
sudo systemctl enable --now buildkite-agent@2

# Follow them all
sudo journalctl -f -u "buildkite-agent@*"

# Or one-by-one
sudo journalctl -f -u buildkite-agent@2

Upgrading

The Buildkite Agent can be upgraded like any other system package:

sudo apt-get update && apt-get upgrade