Ollie B

Gitlab Bot

A bot designed with my own Gitlab instance in mind, that can be used to perform user-defined policies.

Posted on Jul 2, 2025

Gitlab Bot

This project contains the source code for @gl_ops. A user on my private Gitlab instance. The bot has been designed to use a standardised set of policies, allowing it to be deployed in any Gitlab instance, and to apply those policies to projects it is given access to.

IMPORTANT

In order to function, the bot must be given a maintainer role. This will allow it to modify the webhook settings of the projects it is added to. If the maintainer role is not added, the bot will not function on that project in any capacity.

Constraints

Both webhooks and scheduled tasks will be automatically loaded when the bot starts, and will also automatically refresh every 15 minutes.

This may create a small delay when adding the bot to new projects, but will be no longer than 15 minutes.

Automatic Labelling

Labels can automatically be added to issues and merge requests. There is an initial training set of data located in /data/training.json with initial labels located in /data/labels.json.

However, when an issue or merge request is updated, the centralised store of training data (MongoDB) will be updated with the relevant issue/merge request, and the appropriate labels will be updated on that particular record.

The training dataset will be re-trained once every hour to ensure the latest data is being used to train the model with the most accurate labels being applied.

Webhooks

The following webhooks can be used to process API actions:

/webhooks/push - Deals with push events

/webhooks/merge_request - Deals with merge request events

/webhooks/issue - Deals with issue events

/webhooks/note - Deals with comment events

Policies

Custom policies can be created and mapped in the /policies/ directory when deployed. The policies that I use on my Gitlab instance can be found at /policies.

NOTE

This has not yet been fully implemented. The documentation will be updated as the policy system is implemented.

There are two types of policies - reactive and scheduled. These policies are documented below, and are stored in /app/policies when deployed via Docker.

Reactive Policies

NOTE

This documentation is yet to be written.

Scheduled Policies

NOTE

This documentation is yet to be written.

Deployment

WARNING

While currently deployable, this application is still in development. App deployment is done at your own risk and as such, no warranties are provided.

This app can be deployed via docker.

NOTE

This documentation is yet to be written.