GitLab

Sourcery Code Review is available as a GitLab bot that can be installed on any GitLab Cloud repository. Sourcery will review any new merge request made on that repo and provide instant feedback on the MR.

You can use Sourcery for free in GitLab with any public repositories and can try out Sourcery for free for 14 days on private repositories.

You can directly install Sourcery through our website.

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'