Search code examples
automationgitlabbots

how to create a gitlab bot to automate issues handling


We're working on a few project hosted on Gitlab and it would be really convenient for us to have a bot to automate some issues handling.

E.g.: automatically close issues that have been tagged as 'waiting answer from client' more than 20 days ago

I can't find any guide nor tutorial on how doing this, I don't even know if it could be done entirely in GitHub or do I need to create my bot from an external service.


Solution

  • Depending on exactly what you want to do, there are a number of options. I've used all of these approaches for different tasks:

    • If you want to write something from scratch, and have full control over every aspect of the bot's workflow, the python-gitlab library is very nice.
    • If you want something that mainly responds to events gidgetlab is great for this.
    • If you want something that automates a merge-request workflow, you might just want to run an instance of marge-bot.
    • If you want something more sophisticated, and you don't want to start from scratch, it might be worth forking some of GitLab's internal bot repos.

    In your case, if it's mostly a matter of closing stale issues, etc. I would be inclined to fork triage-ops, which already has policies for this already. The policies themselves are written as YAML files, and run as scheduled GitLab pipelines, so it's pretty easy to get started, you just have to specialise the policies to suit your workflow.