Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 961
fudo Avatar asked Jul 01 '20 08:07

fudo


1 Answers

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.
    • The triage-ops repo automates triage on labels and MRs, using the gitlab-triage gem.
    • The async-retrospectives repo automates the generation of end-of-sprint information, which is then posted as an issue. There's a blog post you can read about it.

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.

like image 189
snim2 Avatar answered Oct 10 '22 23:10

snim2