abhi1010 / mention-bot-gitlab

Mention-bot implement for Gitlab.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mention Bot for Gitlab

See: https://github.com/facebook/mention-bot

Find potential reviewer for Merge Reqeust.

How to use

Install buildout:

pip install zc.buildout

buildout bootstrap
bin/buildout

Set your gitlab environment variables

export GITLAB_URL=<gitlab_addr>
export GITLAB_USERNAME=<gitlab_username>
export GITLAB_PASSWORD=<gitlab_password>
export GITLAB_TOKEN=<gitlab_token>

Run Server:

# debug mode
bin/mention_bot

# with gunicorn
bin/gunicorn mention.app:app -w 1 -b :8080 --log-file -

Configuration

The bot can be configured by adding a .mention-bot file to the base directory of the repo. Here's a list of the possible options:

{
    'userBlacklist': [],
    'fileBlacklist': [],
    'maxReviewers': 3,
    'findPotentialReviewers': True,
    'numFilesToCheck': 5,
    'createComment': True,
    'actions': ['open', 'reopen'], // open, close, update
    'skipWIP': True,
    'skipAlreadyAssignedMR': False,
    'skipAlreadyMentionedMR': True
}

Note: The .mention-bot file must be valid JSON.

How Does It Work?

Every time there's a new Merge Request, Gitlab wakes up the mention bot using Webhooks.

Once awakened, the bot will download the diff of the merge request and figure out which files and lines have been touched.

For these, it will download the associated blame to figure out who last touched that line, as they may be a good reviewer.

After running the algorithm described in the next section, it will comment on the pull request notifying those people and go back to sleep.

Installation

This setup is currently installed manually at csqprod-dmz03 in folder /usr/local/mention-bot/mention-bot-lfyzjck/

If you want a quick look at the log file, go into /tmp/bot.log. It contains the logs from the latest run. Full logs are available at /usr/local/mention-bot/mention-bot-lfyzjck/log-mention.log.

Remember to run the zipzp as dev user. Otherwise you will have permission issues.

About

Mention-bot implement for Gitlab.

License:MIT License


Languages

Language:Python 99.1%Language:Shell 0.9%