/gitlab-pkgbot

The Package Bot - A simple service which receives HTTP build triggers from GitLab, gets the built packages and puts them in aptly and RPM repos.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

GitLab Package Bot

A simple service which receives HTTP build triggers from GitLab, gets the built packages and puts them in aptly and RPM repos.

How it works

  • Install pkg-bot on a server reachable by Gitlab as defined below
  • configure the pkgbot with the /etc/gitlab-pkgbot.yaml where you define the repos aswell as a gitlab URL
    • Create a global gitlab token to be used by pkgbot and put into the config
  • Set up a web server which forwards requests to the port defined in /etc/gitlab-pkgbot.yaml (with SSL termination and an IP whitelist containing only the public IP of your gitlab server)
  • You will have a gitlab Repo which contains some kind of package stage to build packages which you want to publish. In this repo:
    • create a .pkg-bot.yml.
    • create a gitlab Webhook which points to your pkgbot server. It needs to run on Job events

Installation

# apt-get install python-yaml python-pip
# pip install python-gitlab

Clone this repository and switch into the directory:

# python setup.py install
# mkdir /var/run/aptly-spooler
# chown mirror:mirror /var/run/aptly-spooler

Configuration & Administration

Configuration

The main config file for the bot is located at /etc/gitlab-pkgbot.yaml.

Administration

It runs as a systemd service. You can view logs with the following command:

# journalctl -u gitlab-pkgbot.service

aptly-spooler

Since aptly can only run one command at once, this script sets up a simple "spooler" for running all aptly commands. This is implemented via a FIFO-Socket located at /var/run/aptly-spooler/fifo.sock. The socket accepts commands seperated by newlines and executes them one by one.

You can manually pipe commands into this spooler as well:

# echo "sleep 10" > /var/run/aptly-spooler/fifo.sock
# echo "ps -efH" > /var/run/aptly-spooler/fifo.sock

It runs as a systemd service. You can view logs with the following command:

# journalctl -u aptly-spooler.service

Mirror preparation

The bot copies the extracted packages into a specific directory tree before adding them to the specific repositories. Meaning the required directories have to be created first:

# cd /path/to/your/mirror/dir
# mkdir -p centos/{6,7} redhat/{6,7} debian/{jessie,wheezy} \
  ubuntu/{trusty,vivid,xenial}mkdir -p centos/{6,7} rhel/{6,7}
# chown -R mirror:mirror /path/to/your/mirror/dir

Contributions

Contributions are more than welcome! Please feel free to open new issues or pull requests.

License

GNU GENERAL PUBLIC LICENSE Version 3

See the LICENSE file.