How to Install and Configure Buildbot on CentOS 7

How Does It Work?

Automation is beneficial in software development due to its repetitive nature and reliability, as it minimizes human errors. It is a fast way for developers to get results, reports, and feedback regarding build and test. With Buildbot, you can automate release and deployment, avoid errors and hassles, and deploy software efficiently.

Prerequisites

  1. You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get a free account in your Alibaba Cloud account. If you don’t know about how to setup your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 1GB RAM and 1 Core processor.
  2. A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.
  3. Domain name must be pointed to your Alibaba Cloud ECS’s IP address
  4. Server’s hostname is set up.
  5. Access to VNC console in your Alibaba Cloud or SSH client installed in your PC
  6. Set up your server’s hostname and create user with root privileges.

Setting Up Your Alibaba Cloud ECS Instance

After completing the prerequisites, log in as a non-root user with sudo privileges. You can refer to this guide if you are not sure how to set up your Alibaba Cloud ECS instance. I have chosen “aareez” as my username.

# sudo yum update
# sudo yum install nano

Upgrade Pip

Pip is a package management system for software packages in Python. For easy installation of Buildbot, I will use pip in this tutorial. To upgrade pip execute the following command:

# sudo pip install --upgrade pip

Install Required Development Tools

For installation of Buildbot, you will require some development tools such as gcc. Execute the following command to install these required tools:

# sudo yum groupinstall 'Development Tools' -y

Install Buildbot

To install Buildbot, I will recommend to use pip for faster installation. You will need to install both Master and Worker for Buildbot to work.

Install Master

For installation of Master, execute the following command:

# sudo pip install Buildbot
# sudo pip install buildbot[tls]

Install Worker

For installation of worker, execute the following command.

# sudo pip install buildbot-worker

Create Buildmaster

As everybody will need to check the project’s status, buildmaster runs on a publicly visible host. To create buildmaster, you will need to create a directory and populate the required files. Use the following command to do so,

# buildbot create-master -r buildbold
# cd buildbold
# sudo cp master.cfg.sample master.cfg

Create Buildbot-www

For installation of buildbot-www, execute the following command.

# sudo pip install buildbot-www

Create Buildbot Views

To install waterfall view for Buildbot, execute the following command.

# sudo pip install buildbot-waterfall-view
# sudo pip install buildbot-grid-view
# sudo pip install buildbot-console-view

Setup Firewalls for HTTP, HTTPS, and Other Ports

If you have activated firewalls, you will have to define a rule in Alibaba Cloud Security Group for your cloud server to add exception for port 80/tcp, 443/tcp and 8010/tcp. You can enable these ports while creating ECS instance, but in case, if you have forgotten to unblock these ports, you can follow the procedure below. By default, these ports are blocked by the firewalls.

Troubleshoot Misconfigured URL

In the process, you may encounter a warning about misconfigured Buildbot URL. To correct it, execute the following command.

# sudo nano master.cfg
c['buildbotURL'] = "http://localhost:8010/"
c['buildbotURL'] = "http://47.254.152.126:8010/"

Install MariaDB

CentOS supports MariaDB server by default. Buildbot supports SQLite, MySQL and Postgres database. In this tutorial, I will use MySQL database. To install MariaDB server, execute the command below.

# sudo yum install mariadb-server -y
# sudo systemctl enable mariadb
# sudo systemctl start mariadb

Install MySQL-Python

For starting Buildbot, MySQL-Python package must be installed. To do so, execute the following command.

# sudo pip install mysqlclient

Create Database

Use MySQL shell to login as root user and execute the following command:

# sudo mysql -u root -p
CREATE DATABASE buildbot CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'buildbot'@'localhost' IDENTIFIED BY 'Password';
GRANT ALL PRIVILEGES ON buildbot.* TO 'buildbot'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Configure Database

You may receive warning about misconfigured Buildbot URL. To correct it, execute the following command.

# sudo nano master.cfg
mysql://buildbot:Password@localhost/buildbot?max_idle=300
c['buildbotNetUsageData'] = None
# sudo buildbot checkconfig

Start Buildbot

Buildmaster database must be upgraded before starting Buildbot. To do so, execute the command below. Remember to change aareez with your own username.

# sudo buildbot upgrade-master /home/aareez/buildbold
# sudo buildbot start

Enable Authentication System

As you may have noticed, you are able to access Buildbot by accessing IP address directly without passing through any authentication system. To secure Buildbot access, follow the steps below.

# sudo nano master.cfg
c['www']['authz'] = util.Authz(
allowRules = [
util.AnyEndpointMatcher(role="admins")
],
roleMatchers = [
util.RolesFromUsername(roles=['admins'], usernames=['aareez'])
]
)
c['www']['auth'] = util.UserPasswordAuth({'aareez': '654321'})
# sudo buildbot restart

Setup Worker

Open the master.cfg file. Remember you should be in your base directory of Buildbot installation. In my case, directory is buildbold.

# sudo nano master.cfg
# sudo buildbot-worker create-worker ~/worker localhost example-worker pass
# sudo buildbot-worker start ~/worker

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com