This document provides internal instructions for setting up Buildbot as a Continuous Integration (CI) and Continuous Deployment (CD) system, as well as a detailed guide for installing Buildbot on Debian and CentOS systems. It also includes steps to configure Nginx as a reverse proxy with HTTPS using Certbot.
- Introduction
- Requirements
- Buildbot CI/CD Setup
- Buildbot Installation on Debian and CentOS 4.1 Introduction 4.2 Prerequisites 4.3 Install Buildbot 4.4 Configure the Master 4.5 Configure the Worker 4.6 Running a Test Build 4.7 Securing the Web Interface 4.8 Configure Nginx as a Reverse Proxy with Certbot
- Contributing
- License
Buildbot is a Python-based system that automates software build, test, and deployment processes. It uses the Twisted library to handle asynchronous communication between a buildmaster and one or more workers. This document covers:
- A modern CI/CD setup using Buildbot.
- An installation guide for Buildbot on Debian and CentOS.
- Steps to secure the Buildbot web interface using Nginx and Certbot.
- Python 3.x
- pip and pipx
- A server running Debian or CentOS
- Buildbot and Buildbot Worker (installed via pipx)
Install Buildbot with the bundle using pipx:
pipx install 'buildbot[bundle]'
-
Create the master directory:
mkdir -p /home/buildbot/master buildbot create-master /home/buildbot/master -
Copy the sample configuration:
cp /home/buildbot/master/master.cfg.sample /home/buildbot/master/master.cfg -
Edit the configuration file:
nano /home/buildbot/master/master.cfgChange the
buildbotURLline to point to your desired URL, for example:c['buildbotURL'] = "https://build.poecdn.cloud/" -
Restart the master to apply changes:
buildbot restart /home/buildbot/master tail -f /home/buildbot/master/twistd.logVerify that the log shows "BuildMaster is running".
-
Create the worker directory:
mkdir -p ~/worker -
Create the worker instance (replace worker_name and password as needed):
buildbot-worker create-worker ~/worker worker_name password -
Update host information:
echo $(hostname) > ~/worker/info/host cat ~/worker/info/host -
Start the worker:
buildbot-worker start ~/workerIf an instance is already running, check its status:
buildbot-worker status ~/worker buildbot-worker stop ~/workerThen start the worker again.
There are two methods:
- Open your browser and navigate to:
https://build.poecdn.cloud/ - Select your builder (e.g., "my-builder").
- Click Force Build to trigger a build manually.
Trigger a build using:
buildbot sendchange --master https://build.poecdn.cloud/ --branch master --revision HEAD --who "Your Name" --comments "Manually triggering build" my-builder
-
Master status:
buildbot status /home/buildbot/master -
Worker status:
buildbot-worker status ~/worker -
Monitor master logs:
tail -f /home/buildbot/master/twistd.log -
Monitor worker logs:
tail -f ~/worker/twistd.log
This section details the installation and configuration of Buildbot on Debian and CentOS systems, setting up both the master and worker on the same machine.
- A server running Debian or CentOS with at least 1 GB of RAM.
- A non-root sudo user.
- A firewall configured to allow SSH and port 8010 (for the Buildbot web interface).
-
Update package list:
sudo apt-get update # For Debian sudo yum update # For CentOS -
Install pip:
sudo apt-get install python-pip # For Debian sudo yum install python-pip # For CentOS -
Install the Buildbot bundle:
sudo -H pip install 'buildbot[bundle]' -
(Optional) Upgrade pip:
sudo -H pip install --upgrade pip -
Verify the installation:
buildbot --versionExpected output similar to:
Buildbot version: X.X.X Twisted version: X.X.X -
Configure the firewall to allow port 8010:
sudo ufw allow 8010 # For Debian (if using ufw) # For CentOS, configure firewalld or iptables to allow port 8010. -
Create a dedicated Buildbot system user and group:
For Debian:
sudo addgroup --system buildbot sudo adduser buildbot --system --ingroup buildbot --shell /bin/bashFor CentOS:
sudo groupadd -r buildbot sudo useradd -r -g buildbot -s /bin/bash buildbot -
Switch to the Buildbot user:
sudo --login --user buildbot
-
Create the master:
buildbot create-master ~/masterThis creates the sample configuration and a SQLite database.
-
Copy the sample configuration:
cp ~/master/master.cfg.sample ~/master/master.cfg -
Edit the configuration file:
nano ~/master/master.cfgChange the
buildbotURLto your server's IP or domain:c['buildbotURL'] = "http://IP_or_site_domain:8010/"Optionally, set:
c['buildbotNetUsageData'] = Noneor c['buildbotNetUsageData'] = 'basic'
-
Check the configuration and start the master:
buildbot checkconfig ~/master buildbot start ~/master -
Access the web interface by navigating to:
http://IP_or_site_domain:8010/
-
Create the worker:
buildbot-worker create-worker ~/worker localhost example-worker pass -
Edit the worker information files:
-
Update the admin file:
nano ~/worker/info/adminReplace the sample text with the appropriate administrator information.
-
Update the host file (use generic system information without specifying the machine model):
nano ~/worker/info/hostFor example:
Debian/CentOS Server - Buildbot version: X.X.X - Twisted version: X.X.X
-
-
Start the worker:
buildbot-worker start ~/worker
- In the web interface, navigate to "Workers" to verify your worker details.
- Click on the default builder (e.g., "runtests") and press Force Build.
- The build should complete successfully; detailed logs can be viewed for each step.
To secure the web interface, add the following lines at the bottom of ~/master/master.cfg (modify as needed):
c['www']['authz'] = util.Authz(
allowRules = [ util.AnyEndpointMatcher(role="admins") ],
roleMatchers = [ util.RolesFromUsername(roles=['admins'], usernames=['admin']) ]
)
c['www']['auth'] = util.UserPasswordAuth({'admin': 'password'})
Check the configuration and restart the master:
buildbot checkconfig ~/master
buildbot restart ~/master
This ensures that administrative functions require authentication.
Using Nginx and Certbot helps secure the Buildbot web interface with HTTPS.
Run the following commands:
sudo apt update
sudo apt install nginx -y
sudo apt install certbot python3-certbot-nginx -y
Edit a new configuration file for your domain (replace "build.poecdn.cloud" with your domain):
sudo nano /etc/nginx/sites-available/build.poecdn.cloud
Insert the following content:
server {
listen 80;
server_name build.poecdn.cloud;
# Redirect all HTTP requests to HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name build.poecdn.cloud;
ssl_certificate /etc/letsencrypt/live/build.poecdn.cloud/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/build.poecdn.cloud/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://127.0.0.1:8010;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}