This document only pertains to Code Climate organizations created prior to January 2018. We are currently not accepting any new non-GitHub repositories.
Code Climate supports GitLab-hosted repositories. This article explains the setup process.
You can add both private and public GitLab repositories to Code Climate. However, all GitLab repositories must be added to Code Climate organizations, which requires a paid plan. This means if a repository is open-source in GitLab, it will be private in Code Climate.
You must be in an organization's Owners group to perform the actions described in this article.
Common reasons why we're unable to connect to a git repo:
1) The git server is behind a firewall, so it's not publicly addressable. If this is the case, you'll need to open holes in your firewall.
2) The server where the git repo located doesn't have the public SSH key that Code Climate provides per repo properly installed. See your repo settings for your public SSH key.
3) The Git URL is incorrect. Double check against your server.
- From your GitLab repository's Project page, locate the URI below your project's description and click SSH. Copy the URI to your clipboard.
We do not currently support HTTPS for GitLab-hosted repositories.
- From your Code Climate Dashboard, within the organization you want to add the repository to, navigate to the URI text box.
Tip: To get to this text box, select the options to add a non-open source, non-GitHub repository. The click-by-click steps differ based on various factors. While navigating, you may be prompted to enter an organization name.
- Enter the repository's URI.
- Optional: If you don't want the branch named master set as the default branch, click Change and enter a different branch name.
- Click Add Repo.
- Click the "copy to clipboard" icon to copy your new public SSH key to your clipboard.
- Back in GitLab, click Settings in the upper-right.
- Click Deploy Keys in the left navigation menu.
- Click New Deploy Key.
- Enter a Title and paste the key into the Key field.
- Click Create.
- Back in Code Climate, click This Deploy Key Is In Place.
To complete your repository setup, you'll want to install our webhook. This hook is what notifies us of certain events happening in your repository, including commits made to your default branch. When we receive the notification, we'll run a new analysis on the spot.
If you don't install our webhook, we'll check for new commits on a poll.
- From your GitLab repository's Project page, click Settings.
- Click Web Hooks.
Paste the following into the URL field: https://codeclimate.com/api/repos/repo_id/refresh?api_token=api_token. In this URL:
repo_idwith the ID listed in the browser's URL bar when viewing the repository Feed page.
api_tokenwith the token listed in the organization's Settings menu, in the Integrations tab. When looking for this token, ensure you are not viewing a repository’s Integrations tab -- since API tokens live at the organization-level, it is accessed in your organization’s Integrations tab.
Ensure the default settings are checked.
- Click Add Web Hook. Your GitLab repository will now trigger a new analysis automatically each time you make a commit to your default branch.
Code Climate also supports integration for status updates on GitLab Merge Requests. This integration requires setup on both the Code Climate and GitLab sides. On the GitLab side, set up a web hook from your GitLab repository's Project page (the same process as described in the Webhook section above), with the following options:
- Select Merge Request events as the trigger, and enter
https://codeclimate.com/webhooksas the URL (replace
codeclimate.comwith the address of your Code Climate: Enterprise instance if you are using one).
- Click Add Web Hook. Your GitLab repository will now trigger a new analysis automatically each time you make changes to Merge Requests.
- On the Code Climate side, click Settings in the top navigation and then Integrations in the menu on the left. Find GitLab Merge Requests and click on Set Up
- On the next page, fill in the Access Token field with a personal access token generated from your profile page on GitLab. Replace the GitLab API Base URL with the root of a GitLab Enterprise Edition instance if you are using one.
- Click Save. Code Climate will now send status updates when Merge Requests are analyzed