Automation of label assignment for GitLab merge requests.
6.3K
Solves the problem of missing automation of labeling merge requests in GitLab. Based on merge request pipelines, labels are automatically assigned using various configuration options.
APPEND or OVERRIDEThe following configuration variants are currently supported.
Assigns labels based on the paths of the changed files. Compares the git diff between the source and target branch of the specific merge request.
Assigns labels based on the commit messages of the made changes. Compares the git log between the source and target branch of the specific merge request.
In order to use gitlab-mr-labeler you must follow these steps:
You need ~ 7 minutes to get your initial setup up and running 🚀.
This tool needs a PAT in order to be able to assign labels on merge requests. Just follow the steps as described in the GitLab documentation. See Create a project access token.
Make sure to set the following variables:
REPORTER (any other role should be sufficient as well)apiAdd your newly created token as an CI/CD variable. See Define a CI/CD variable in the UI.
In order to configure which labels should be applied you need to provide a json configuration file. You can place the configuration file anywhere in your project repository. This file will be referenced when the gitlab-mr-labeler CLI is called.
You must define the following properties. If you want to disable any label matcher just set the equivalent property to an empty object ({}).
APPEND or OVERRIDE// .gitlab/gitlab-mr-labeler.config.json
{
"assignMethod": "APPEND",
"gitLogMessages": {
"feature": ["^feat"]
},
"gitDiffPaths": {
"dependencies": ["package.json$"]
}
}
Check out the predefined examples to find a good starting point to label your merge requests 🔥.
To automatically determine and assign the appropriate labels you need to define a merge request pipeline job that executes the gitlab-mr-labeler CLI with your created project access token and the relative path to your json configuration file.
# .gitlab-ci.yml
stages:
- prepare
gitlab_mr_labeler:
stage: prepare
image: docker.io/marhali/gitlab-mr-labeler:latest
script: gitlab-mr-labeler $MY_PROCESS_ACCESS_TOKEN .gitlab/gitlab-mr-labeler.config.json
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
Distributed under the MIT License. See LICENSE for more information.
Marcel Haßlinger - @marhali_de - Portfolio Website
Project Link: https://github.com/marhali/gitlab-mr-labeler
If this tool helps you to reduce development time, you can give me a cup of coffee :)
Content type
Image
Digest
sha256:7726ef1d3…
Size
58.4 MB
Last updated
over 1 year ago
docker pull marhali/gitlab-mr-labeler