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.

Troubleshooting

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.

How To

  1. 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.

  1. 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.

  1. Enter the repository's URI.
  1. Optional: If you don't want the branch named master set as the default branch, click Change and enter a different branch name.
  1. Click Add Repo.
  2. Click the "copy to clipboard" icon to copy your new public SSH key to your clipboard.
  1. Back in GitLab, click Settings in the upper-right.
  1. Click Deploy Keys in the left navigation menu.
  1. Click New Deploy Key.
  1. Enter a Title and paste the key into the Key field.
  2. Click Create.
  1. Back in Code Climate, click This Deploy Key Is In Place.
  1. Code Climate will begin analyzing your repository right away. You'll see a "processing" indicator until our analysis is finished (which is usually within 5-15 minutes). Your Feed page will be empty until there's a new commit for us to review and until we find something worth telling you about.

Webhook

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.

  1. From your GitLab repository's Project page, click Settings.
  1. Click Web Hooks.
  1. Paste the following into the URL field: https://codeclimate.com/api/repos/repo_id/refresh?api_token=api_token. In this URL:

    • Replace repo_id with the ID listed in the browser's URL bar when viewing the repository Feed page.
    • Replace api_token with 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.
  2. Ensure the default settings are checked.

  3. Click Add Web Hook. Your GitLab repository will now trigger a new analysis automatically each time you make a commit to your default branch.

Merge Request Integration

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:

  1. Select Merge Request events as the trigger, and enter https://codeclimate.com/webhooks as the URL (replace codeclimate.com with the address of your Code Climate: Enterprise instance if you are using one).
  2. Click Add Web Hook. Your GitLab repository will now trigger a new analysis automatically each time you make changes to Merge Requests.
  3. 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
  1. 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.
  1. Click Save. Code Climate will now send status updates when Merge Requests are analyzed

GitLab


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.