Installing Buildkite Agent on Red Hat, CentOS and Amazon Linux

The Buildkite Agent can be installed on Redhat, CentOS and Amazon Linux using our yum repository.

Installation

Firstly, add our yum repository for your architecture (run uname -m to find your system’s arch).

For 64-bit (x86_64):

sudo sh -c 'echo -e "[buildkite-agent]\nname = Buildkite Pty Ltd\nbaseurl = https://yum.buildkite.com/buildkite-agent/stable/x86_64/\nenabled=1\ngpgcheck=0\npriority=1" > /etc/yum.repos.d/buildkite-agent.repo'

For 32-bit (i386):

sudo sh -c 'echo -e "[buildkite-agent]\nname = Buildkite Pty Ltd\nbaseurl = https://yum.buildkite.com/buildkite-agent/stable/i386/\nenabled=1\ngpgcheck=0\npriority=1" > /etc/yum.repos.d/buildkite-agent.repo'

Then, install the agent:

sudo yum -y install 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, and tail the logs:

# For distributions with systemctl
sudo systemctl enable buildkite-agent && sudo systemctl start buildkite-agent
sudo tail -f /var/log/messages

# For distributions without systemctl (such as Amazon Linux)
sudo service buildkite-agent start
sudo tail -f /var/log/buildkite-agent.log

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
  • Hooks: /etc/buildkite-agent/hooks/
  • Builds: /var/buildkite-agent/builds/
  • Logs, depending on your system:
    • journalctl -f -u buildkite-agent (systemd)
    • /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 systemd 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 /usr/lib/systemd/system/buildkite-agent.service /etc/systemd/system/buildkite-agent@.service

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

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

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

For older systems without systemd (such as Amazon Linux) you instead use:

sudo cp /etc/init.d/buildkite-agent /etc/init.d/buildkite-agent-2
sudo chkconfig --add buildkite-agent-2
sudo service buildkite-agent-2 start

Upgrading

sudo yum clean expire-cache && yum update buildkite-agent