Set Up Oauth Login (Self-Hosted)

Modified on Wed, 28 Sep 2022 at 01:13 PM

Via Github, Gitlab, or Bitbucket

A service provider is the product you use to host your source code. Codecov integrates with GitHub, Github Enterprise, Bitbucket, Bitbucket Server (formally Stash), GitLab and GitLab Enterprise. Please choose one or more provider to link with your Codecov Enterprise.


?   Do not indent your service provider configuration

A common configuration error is to indent the service provider configuration under the setup block in your codecov.yml. This will result in errors when running codecov enterprise.

When adding service providers, be sure to add them to the codecov.yml as follows:

setup: # various setup configs github_enterprise: # provider config

GitHub.com

Below is the guide to link Github.com to your Codecov Enterprise.

Step 1 - Create a new application

  1. Create a new application at https://github.com/settings/applications/new

  2. Fill in an Application Name, ex Codecov Enterprise

  3. (optional) Upload Codecov avatar

  4. Specify Homepage URL to your CE endpoint https://codecov-enterprise-hostname.com

  5. Specify the Authorization Callback URL https://codecov-enterprise-hostname.com/login/github

  6. Click Register Application

    1. Store the Client ID and Client Secret for use in the configuration below

Step 2 - Configuration

Append the information collected in step 1 in your enterprise codecov.yml.

YAML

1github: 2  client_id: "Client ID" 3  client_secret: "Client Secret" 4 

Step 3 - Restart

Restart your Codecov Enterprise to complete the integration.

GitHub Enterprise

Your Github Enterprise (GHE) is a self-hosted instance of Github. It likely located behind your firewall. Codecov Enterprise (CE) will need to communicate with your GHE to function properly. 

Please follow these configuration steps to setup your instance properly.

Please replace https://enterprise-hostname.com with the root url of your GHE.

Step 1 - Create a new application

  1. Create a new application at https://enterprise-hostname.com/settings/applications/new

  2. Fill in an Application Name, ex Codecov Enterprise

  3. (optional) Upload Codecov avatar

  4. Specify Homepage URL to your CE endpoint https://codecov-enterprise-hostname.com

  5. Specify the Authorization Callback URL https://codecov-enterprise-hostname.com/login/ghe

  6. Click Register Application

    1. Store the Client ID and Client Secret for use in the configuration below

Step 2 - Configuration

Append the information collected in step 1 in your enterprise codecov.yml.

YAML

1github_enterprise: 2  url: "https://enterprise-hostname.com" 3  api_url: "https://enterprise-hostname.com/api/v3" 4  client_id: "Client ID" 5  client_secret: "Client Secret" 6 

Step 3 - Restart

Restart your Codecov Enterprise to complete the integration.

Bitbucket.org

Below is the guide to link Bitbucket.org to your Codecov Enterprise.

Step 1 - Add OAuth consumer

  1. Create a new OAuth consumer

    1. Goto https://bitbucket.org/account/user/USERNAME/oauth-consumers/new

    2. Replace USERNAME with your username or team name above

    3. You may review Bitbucket's guide too

  2. Fill in an Application Name, ex Codecov Enterprise

  3. Fill in an Callback URL to http://codecov.domain.com/login/bitbucket

  4. Fill in an URL to http://codecov.domain.com/bb

  5. Toggle the permissions as seen in the image below.

  6. Click Save

  7. In your list of OAuth Consumers click on your new entry.

    1. Copy the Key and Secret for your codecov.yml


Step 2 - Configuration

Append the information collected in step 1 in your enterprise codecov.yml.

Text

1bitbucket: 2  client_id: "key" 3  client_secret: "secret" 4 

Step 3 - Restart

Restart your Codecov Enterprise to complete the integration.

Bitbucket Server / Bitbucket Enterprise

Bitbucket Server (BBS, formerly Stash) is a self-hosted instance of Bitbucket. Codecov Enterprise (CCE) will need to communicate with your BBS to function properly. Please follow these configuration steps to setup your instance properly.

Step 1 - Create a new Application Link

  1. Create a unique Consumer Key, ex UUID: a49d1f9e-294c-4cd6-a44c-e5e4440e67c9

  2. Configure Application Link at <BBS>/plugins/servlet/applinks/listApplicationLinks

  3. Enter the URL of your Codecov Enterprise instance (<CCE>) next to Create a new link button

  4. Fill in application details

    1. Application Name: Codecov

    2. Application Type: Generic Application

    3. Leave the remaining field empty.

  5. Click *Continue

  6. Now the link is added. Please click Edit on the Codecov link.

  7. Click on the tab Incoming Authorization

  8. Fill in the details:

    1. Consumer Key with your generated client id.

    2. Consumer Name with Codecov

    3. Public Key (see below)

    4. Consumer Callback URL with <CCE>/login/bitbucket_server

  9. Click Save

You should now see Codecov in your Application Links

Bitbucket Server - Public Key1MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9d2iMTFiXglyvHmp5ExoNK2X8nxJ+1mlxgWOyTUpTrOKRiDUbZoZID3TP8CobQ5BsqDOSawHyi+Waf9Ca+iYoTu1fa8yZUreQXAdaK1u61Mn2XCkmITE/N5kvbYjDEWA1Dwb6CsvVkYZXo/Eq1X/3yrLXWKDNEnm0Cq48PFWqMQIDAQAB 2 

Step 2 - Configuration

Append the information collected in step 1 in your enterprise codecov.yml.

YAML

1bitbucket_server: 2  url: "<BBS>" 3  client_id: "Consumer Key from above" 4 

Step 3 - Restart Codecov container

Restart your Codecov Enterprise container to complete the integration.

GitLab.com

GitLab.com follows the same install setup as GitLab CE/EE below.

GitLab CE/EE

Your Gitlab Enterprise (CE/EE) (aka GLE) is a self-hosted instance of Gitlab. It's likely located behind your firewall. Codecov Enterprise (CE) will need to communicate with your GLE to function properly. Please follow these configuration steps to setup your instance properly.

Link your Gitlab Enterprise to Codecov Enterprise

Please replace https://enterprise-hostname.comwith the root url of your GLE.


?   Using GitLab.com?

If you're using gitlab.com's hosted offering, you should use https://gitlab.com as your root url.

Step 1 - Create a new application

  1. Create a new application at https://enterprise-hostname.com/profile/applications

  2. Fill in an Application Name, ex Codecov Enterprise

  3. Specify the redirect URI for your CE endpoint https://codecov-enterprise-hostname.com/login/gitlab_enterprise

  4. Select all scopes except sudo

  5. Click Submit

    1. Store the Application Id and Secret for use in the configuration below

Step 2 - Configuration

Append the information collected in step 1 in your enterprise codecov.yml.

YAML

1gitlab_enterprise: 2  url: "https://enterprise-hostname.com" 3  client_id: "Application Id" 4  client_secret: "Secret" 5 

Step 3 - Restart Codecov container

Restart your Codecov Enterprise container to complete the integration.

Have a self-signed SSL certificate? Add your ssl.pem with this documentation.

Include ssl.pem for self-signed SSL

Two steps: (1) add the ssl pem location to your codecov.yml, (2) include it in your docker run

YAML

1gitlab_enterprise: 2  ssl_pem: "/gle.ssl.pem" 3 

Shell

1docker run -it --rm \ 2  -v "$PWD/codecov.yml:/codecov.yml" \ 3  -v "$PWD/gle.ssl.pem:/gle.ssl.pem" \  # this is added 4  --link codecov-redis:redis \ 5  --link codecov-postgres:postgres \ 6  codecov/enterprise:v?.?.? 

 



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article