Getting a Sentry project for each of your Gitlab repositories is just one MR merge away!
Gitlab2Sentry will create a Sentry project associated to each of your Gitlab repositories using a Merge Request based automated workflow.
Any new Gitlab repository you create will be offered a Sentry project if you accept (merge the proposal MR) it with respect to the Gitlab group owning it!
-
After creating your new project on Gitlab,
gitlab2sentry
will create a first Merge Request asking if you want it to create an associated Sentry project for it. This Merge Request will contain the creation of a.sentryclirc
file which, if you merge it, will be contributed back the newly created Sentry projectDSN
for this project. -
If you merged the first Merge Request,
gitlab2sentry
will create a second one to update the newly created.sentryclirc
file with theDSN
of the sentry project. Moreover, after the merge of the first Merge Requestgitlabsentry
will create a newsentry project
, update its rate limit and save theDSN
inside.sentryclirc
. Once you have merged this second Merge Request everything will be set up!
NOTE: Gitlab2Sentry
looks only for group projects and searches for MRs having specific keyword inside (check "Configuration" section)
You can install all requirements for this project with:
python3 -m venv venv
pip3 install -r requirements.txt
source venv/bin/activate
After the installation of all requirements you have to:
export SENTRY_URL=<your sentry's url>
export SENTRY_TOKEN=<your sentry token>
export SENTRY_ENV=<your environment - default production>
export GITLAB_TOKEN=<your gitlab token>
export GITLAB_URL=<your gitlab url>
python3 run.py
We prefer to deploy and manage gitlab2sentry
with helm
. Inside helm/
folder you can find an example deployment.
You can upgrade your deployment with:
make upgrade
Gitlab2Sentry
requires some configuration in 3 specific files.
All configuration variables here
- First of all you have to configure the
helm/values-production.yaml
file where everything is configured for thegitlab2sentry
service. Here you can find a description for every field:
# Sentry values
- name: SENTRY_TOKEN
valueFrom:
secretKeyRef:
key: SENTRY_TOKEN
name: gitlab2sentry-production
- name: SENTRY_DSN
value: your-sentry-dsn
- name: SENTRY_URL
value: your-sentry-url
- name: SENTRY_ORG_SLUG
value: your-sentry-organization-slug
# Gitlab values
- name: GITLAB_TOKEN
valueFrom:
secretKeyRef:
key: GITLAB_TOKEN
name: your-secret
- name: GITLAB_URL
value: your-gitlab-url
# DSN MR (1) values
- name: GITLAB_DSN_MR_CONTENT
value: the content of your dsn mr
- name: GITLAB_DSN_MR_DESCRIPTION
value: the description of your dsn mr
- name: GITLAB_DSN_MR_BRANCH_NAME
value: your-branch-name
- name: GITLAB_DSN_MR_TITLE
value: "your-dsn-mr-title"
# Sentryclirc MR (2) values
- name: GITLAB_SENTRYCLIRC_MR_CONTENT
value: your-sentryclirc-mr-content
- name: GITLAB_SENTRYCLIRC_MR_DESCRIPTION
value: your-sentryclirc-mr-description
- name: GITLAB_SENTRYCLIRC_MR_BRANCH_NAME
value: your-sentryclirc-mr-branch-name
- name: GITLAB_SENTRYCLIRC_MR_FILEPATH
value: .sentryclirc
- name: GITLAB_SENTRYCLIRC_MR_COMMIT_MSG
value: your-commit-msg
- name: GITLAB_SENTRYCLIRC_MR_TITLE
value: "your sentryclirc mr title"
# Gitlab configuration values
- name: GITLAB_AUTHOR_NAME
value: author-name
- name: GITLAB_AUTHOR_EMAIL
value: your-author-email
- name: GITLAB_GRAPHQL_SUFFIX
value: api/graphql
# - name: GITLAB_MENTIONS
# value:
# - "@all"
- name: GITLAB_MENTIONS_ACCESS_LEVEL
value: 40 # maintainer
- name: GITLAB_CREATION_DAYS_LIMIT
value: 60 # Max days old per project
- name: GITLAB_MR_KEYWORD
value: sentry # key word for searching mrs
- name: GITLAB_REMOVE_SOURCE
value: true # If the mr will remove the source branch
- name: GITLAB_GROUP_IDENTIFIER
value: your-group-identifier # will look only for group projects having this identifier
- name: GITLAB_AIOHTTP_TIMEOUT
value: 60
- name: GITLAB_GRAPHQL_PAGE_LENGTH
value: 100
- name: GITLAB_MR_LABEL_LIST
value: "sentry,your-label" # comma separated list of labels for the mr
-
If you want to follow the
helm
deployment process you will have to fill your details into thehelm/values-production.yaml
andhelm/Chart.yaml
. -
You can update
REG ?= your-registry
andNS ?= your-namespace
values insideMakefile
.
If you want to update a specific project (for example if the project has a very big name or is older than the GITLAB_CREATION_DAYS_LIMIT
value), you can run the gitlab2sentry
manually.
-
First, you have to
export
all env variables which are listed above in thehelm/values-production.yaml
file. -
Next you can run the following commands:
>>> from gitlab2sentry import Gitlab2Sentry
>>> g2s = Gitlab2Sentry()
>>> g2s.update(full_path="projects_full_path", custom_name="optional_custom_name")
Numberly decided to Open Source this project because it saves a lot of time internally to all our developers and helped foster the mass adoption of Sentry in all our Tech teams. We hope this project can benefit someone else.
Feel free to ask questions, suggest improvements and of course contribute features or fixes you might need!