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,
gitlab2sentrywill 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.sentryclircfile which, if you merge it, will be contributed back the newly created Sentry projectDSNfor this project. -
If you merged the first Merge Request,
gitlab2sentrywill create a second one to update the newly created.sentryclircfile with theDSNof the sentry project. Moreover, after the merge of the first Merge Requestgitlabsentrywill create a newsentry project, update its rate limit and save theDSNinside.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/activateAfter 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.pyWe prefer to deploy and manage gitlab2sentry with helm. Inside helm/ folder you can find an example deployment.
You can upgrade your deployment with:
make upgradeGitlab2Sentry requires some configuration in 3 specific files.
All configuration variables here
- First of all you have to configure the
helm/values-production.yamlfile where everything is configured for thegitlab2sentryservice. 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
helmdeployment process you will have to fill your details into thehelm/values-production.yamlandhelm/Chart.yaml. -
You can update
REG ?= your-registryandNS ?= your-namespacevalues 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
exportall env variables which are listed above in thehelm/values-production.yamlfile. -
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!