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.

  1. Sign up for a Sourcery account.
  2. Email GitLab@sourcery.ai to request access to the beta program.
  3. Add the Sourcery review pipeline below into your projects .gitlab-ci.yml
  4. Create a Project/Group Access Token for posting reviews to merge requests - SOURCERY_AI_BOT
  5. Go to Settings > Access Tokens
  6. Create a new Access Token with name SOURCERY_AI_BOT, role Developer, and scope api
  7. Click on "Create access token"
  8. Store your Sourcery token as a Project/Group CI/CD variable - SOURCERY_TOKEN
  9. First get your Sourcery token
  10. Go to Settings > CI/CD
  11. Expand the Variables section.
  12. Add a new variable:
    • Key: SOURCERY_TOKEN.
    • Value:
    • Flags:
    • โŒ Protect variable
    • โœ… Mask variable
    • โŒ Expand variable reference
  13. Click on "Add variable"
  14. 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'
Was this page helpful?