Self Hosted GitLab
We currently are offering a beta program of Sourcery for self-hosted GitLab repos. To get started:
To get access to the alpha program and set up Sourcery in GitLab please follow the steps below.
- Sign up for a Sourcery account.
- Email GitLab@sourcery.ai to request access to the beta program.
- Add the Sourcery review pipeline below into your projects
.gitlab-ci.yml
- Create a Project/Group Access Token for posting reviews to merge requests -
SOURCERY_AI_BOT
- Go to Settings > Access Tokens
- Create a new Access Token with name
SOURCERY_AI_BOT
, roleDeveloper
, and scopeapi
- Click on "Create access token"
- Store your Sourcery token as a Project/Group CI/CD variable -
SOURCERY_TOKEN
- First get your Sourcery token
- Go to Settings > CI/CD
- Expand the Variables section.
- Add a new variable:
- Key:
SOURCERY_TOKEN
. - Value:
- Flags:
- โ Protect variable
- โ Mask variable
- โ Expand variable reference
- Key:
- Click on "Add variable"
- Open a new merge request to see Sourceryโs comments on your code changes.
sourcery_review:
stage: test
image: python:slim
script:
- pip install --pre sourcery-nightly
- sourcery login --token $SOURCERY_TOKEN
- |
sourcery assistant review gitlab-merge-request \
--gitlab-token $SOURCERY_AI_BOT \
--project $CI_PROJECT_PATH \
--merge-request $CI_MERGE_REQUEST_IID \
--commit $CI_COMMIT_SHA
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'