|
| 1 | +# gitlab2sentry |
| 2 | + |
| 3 | +This project aims to automate Sentry project creation. Moreover it aims to create a sentry project for every gitlab team's project. |
| 4 | + |
| 5 | +The script aims to add sentry for every new project you have created. |
| 6 | + |
| 7 | + |
| 8 | +## Two-Steps process |
| 9 | + |
| 10 | +1. After creating your new project, in your gitlab, ```gitlab2sentry``` will create the first Pull Request. This pull request will contain the creation of the ```.sentryclirc``` file. Although, it will not contain the ```DSN``` for this project and no project will be created to ```sentry``` |
| 11 | + |
| 12 | +2. Once the user has merged the first Pull request, ```gitlab2sentry``` will create the second Pull Request. This pull request will update the newly created ```.sentryclirc``` file with the ```DSN``` of the sentry project. Moreover, after the merge of the first Pull Request ```gitlabsentry``` will create a new ```sentry project```, update its rate limit and save the ```DSN``` inside ```.sentryclirc```. Once the user has merged the second pull request everything will be set up. |
| 13 | + |
| 14 | +**NOTE**: ```Gitlab2Sentry``` looks only for group projects and searches for PRs having specific keyword inside (check "Configuration" section) |
| 15 | + |
| 16 | + |
| 17 | +## Run locally |
| 18 | + |
| 19 | +You can install all requirements for this project with |
| 20 | + |
| 21 | +``` |
| 22 | +python3 -m venv venv |
| 23 | +pip3 install -r requirements.txt |
| 24 | +source venv/bin/ac |
| 25 | +``` |
| 26 | + |
| 27 | +After the installation of all requirements you have to: |
| 28 | + |
| 29 | +``` |
| 30 | +export SENTRY_URL=<your sentry's url> |
| 31 | +export SENTRY_TOKEN=<your sentry token> |
| 32 | +export SENTRY_ENV=<your environment - default production> |
| 33 | +export GITLAB_TOKEN=<your gitlab token> |
| 34 | +export GITLAB_URL=<your gitlab url> |
| 35 | +python3 run.py |
| 36 | +``` |
| 37 | + |
| 38 | +## Deployment |
| 39 | + |
| 40 | +We prefer to deploy and manage ```gitlab2sentry``` with ```helm```. Inside ```helm/``` folder you can find an example deployment. |
| 41 | + |
| 42 | +You can upgrade your deployment with: |
| 43 | + |
| 44 | +``` |
| 45 | +make upgrade |
| 46 | +``` |
| 47 | + |
| 48 | +## Configuration |
| 49 | + |
| 50 | +```Gitlab2Sentry``` requires some configuration in 3 specific files. |
| 51 | + |
| 52 | +1. First of all you have to configure the ```g2s.yaml``` file where everything is configured for the ```gitlab2sentry``` service. Here you can find a description for every field: |
| 53 | + |
| 54 | +``` |
| 55 | +sentry: |
| 56 | + # Sentry configuration. |
| 57 | + slug: <your sentry organization> |
| 58 | +gitlab: |
| 59 | + # DSN PR configuration. |
| 60 | + dsn_mr: |
| 61 | + # Default values for dsn (2nd) pull request configuration. |
| 62 | + content: | |
| 63 | + ## File generated by gitlab2sentry |
| 64 | + [defaults] |
| 65 | + url = {sentry_url} |
| 66 | + dsn = {dsn} |
| 67 | + description: <your description in the DSN PR> |
| 68 | + branch_name: <default dsn branch name> |
| 69 | + title: <default title of the dsn mr> |
| 70 | + # Sentryclirc PR configuration. |
| 71 | + sentryclirc_mr: |
| 72 | + # Default values for .sentryclirc (1st) pull request configuration. |
| 73 | + content: | |
| 74 | + ## File generated by gitlab2sentry |
| 75 | + [defaults] |
| 76 | + url = {sentry_url} |
| 77 | + description: <your description in the sentryclirc MR> |
| 78 | + branch_name: <your sentryclirc branch_name |
| 79 | + filepath: .sentryclirc |
| 80 | + commit_message: <commit message> |
| 81 | + title: <default title of the sentryclirc mr> |
| 82 | + # Gitlab configuration. |
| 83 | + config: |
| 84 | + author: |
| 85 | + name: <name> |
| 86 | + email: <email> |
| 87 | + graphql_suffix: <endpoint of gitlab graphql> |
| 88 | + # Mention some specific people. |
| 89 | + mentions: |
| 90 | + - "@<mention> |
| 91 | + - # everyone you want to include on those MRs |
| 92 | + # If no "mentions" field is included, you have to define |
| 93 | + # The access_level of those who will be mentioned in your PR. |
| 94 | + mentions_access_level: 40 |
| 95 | + # This keyword must be included in your Pull Request title. |
| 96 | + # Gitlab2sentry will search with this keyword for PRs |
| 97 | + keyword: sentry |
| 98 | + # How old has to be the projects checked from gitlab2sentry |
| 99 | + creation_days_limit: 60 |
| 100 | + # Do you want to remove the source branch after merge? |
| 101 | + remove_source: true |
| 102 | + # Gitlab2Sentry searches only for group projects. |
| 103 | + group_identifier: <define a keyword for the groups you want to include> |
| 104 | + # Configure the aiohttp timeout for the GraphQL API of gitlab |
| 105 | + graphql_aiohttp_timeout: 40 |
| 106 | + # How many items per page will have the response of the GraphQL API. |
| 107 | + graphql_page_length: 100 |
| 108 | +``` |
| 109 | + |
| 110 | +2. If you want to follow the ```helm``` deployment process you will have to fill your details into the ```helm/values-production.yaml``` and ```helm/Chart.yaml```. |
| 111 | + |
| 112 | +3. You can update ```REG ?= your-registry``` and ```NS ?= your-namespace``` values inside ```Makefile```. |
0 commit comments