For the complete documentation index, see llms.txt. This page is also available as Markdown.

Integrate OAuth with Git experience

Configure your credentials for Git experience.

You can store configurations for your resources, such as pipelines and input sets, in Git using Harness Git Experience. Harness fetches user credentials from the Harness account and uses the corresponding user name as the author of the commit.

You can push configuration changes using your own credentials by integrating OAuth with Git. When you integrate OAuth with Git Experience, the credentials are stored in your Harness account user profile. These credentials are used for any subsequent commits.

IMPORTANT

Harness will continue to use the user name corresponding to the account if you do not integrate OAuth with Git Experience.

This topic explains how to configure OAuth for Git Experience in Harness.

Configure OAuth for Git provider

Harness supports OAuth integration for the following Git providers:

  • GitHub

  • GitLab

  • Bitbucket SaaS

  • Self-hosted Bitbucket

NOTE

Harness does not support OAuth integration for Azure Repos or on-premises Git systems.

This topic explains how to configure OAuth for GitHub.

To configure your credentials for Git:

  1. Go to your user profile in Harness.

  2. In Connect to a Git Provider, select GitHub.

  3. Click Connect. The OAuth settings for the selected Git provider appear.

  4. Click Authorize. Harness fetches the corresponding OAuth token associated with the Git provider and displays it under Access token for Git providers.

NOTE

You can delete access tokens you no longer need. Under Access tokens for Git providers, click the Delete icon for the Git provider token. A confirmation message appears. After you confirm, Harness removes the configuration.

Configure OAuth for GitHub Enterprise

Harness supports OAuth integration for GitHub Enterprise. As a prerequisite, you need to create an OAuth App in your GitHub Enterprise instance.

Go to Creating an OAuth App to create an OAuth App.

As you begin setting up the OAuth App:

  • You must provide the Authorization callback URL. Initially, you can provide any valid URL to proceed. Later, this URL will be updated to the URL provided during New Provider set-up.

  • Keep the Client ID and Client Secret handy. You will need them to create the provider in Harness.

NOTE

OAuth for GitHub Enterprise requires the PIPE_ENABLE_GITHUB_ENTERPRISE_PROVIDER_FLOW feature flag. Contact Harness Support to enable the feature.

To configure your credentials for GitHub Enterprise:

  1. Navigate to Account Settings in Harness.

  2. Select Providers, then click New Provider.

  1. Select GitHub as a provider.

  2. Enter the Name and Domain URL of the provider. The Domain URL is the URL of your GitHub Enterprise instance.

  3. Specify the Secret Manager. This is where the token related to GitHub Enterprise will be stored.

  4. Specify the Delegate Selector, then click Continue.

  1. Copy the Redirect URL provided on the Harness Credentials page and use it to update the Authorization callback URL in your GitHub Enterprise OAuth App.

  1. Copy the Client ID and generated Client Secret from your GitHub Enterprise OAuth App and use them to complete the provider's setup.

After you configure the GitHub Enterprise provider, navigate to your user profile. Select Profile Overview. Under Connect to a Provider, click Select a Provider. Select Custom Provider, select the provider you created, then click Connect.

On the GitHub authorization page, click Authorize. Harness creates the access token.

Configure OAuth for Self-hosted Bitbucket provider

To configure your credentials for a self-hosted Bitbucket provider:

  1. Go to your user profile in Harness.

  2. Under Account providers, click New Provider.

  1. Select Bitbucket as a provider.

  2. Enter the Name and Domain URL of the provider.

  3. Specify the Secret Manager. This is where you have the access token related to the BitBucket stored.

  4. Specify the Delegate Selector, then click Continue.

  1. Copy the Redirect URL provided on the Harness Credentials page.

  2. Navigate to the settings for your self-hosted Bitbucket instance. Select Application Links, then click Create Link.

  3. Enter the Name. Under Redirect URL, enter the URL from the Bitbucket Configuration step, then save it.

  4. Return to Application Links. Open the settings for the application, then click View Credentials. Copy the Client ID and Client Secret. Use them to configure the provider on the Harness Credentials page, then save it.

After you configure the Bitbucket provider, navigate to your user profile. Select Profile Overview. Under Connect to a Provider, click Select a Provider. Select On-Prem, select the provider you created, then click Connect.

On the Bitbucket page, click Allow. Harness creates the access token.

Configure OAuth for Self-hosted Gitlab provider

OAuth configuration for self-hosted and on-premises GitLab requires the PIPE_ENABLE_GITLAB_ON_PREM_FLOW feature flag. Contact Harness Support to enable the feature.

Harness Delegate version 843xx or later is required for this feature.

To configure your credentials for a self-hosted GitLab provider:

  1. Go to your user profile in Harness.

  2. Under Account providers, click New Provider.

  1. Select GitLab as a provider.

  2. Enter the Name and Domain URL of the provider.

  3. Specify the Secret Manager. This is where you have the access token related to the Gitlab stored.

  4. Specify the Delegate Selector, then click Continue.

  1. Go to User Settings, then select Applications. Enter the Name and Redirect URI from the GitLab Configuration step. Add the Scopes, then click Save Application.

  1. Once you save the application, copy the Application ID and Secret and use these to configure the provider on the Harness Credentials page.

After you configure the GitLab provider, navigate to your user profile. Select Profile Overview. Under Connect to a Provider, click Select a Provider. Select On-Prem, select the provider you created, then click Connect.

On the GitLab page, click Authorize. Harness creates the access token.

Commit changes to Git with the configured OAuth token

To commit changes to Git using the configured OAuth token:

  1. Go to an existing remote pipeline or create a new one.

  2. Edit the pipeline and select Save. The Save Pipelines to Git settings appear. Harness displays the user name being used for this commit.

  3. Select Save.

    Configure OAuth or use connector credentials

    If you have not configured OAuth for Git, Harness prompts you to set up an access token in your user profile. To commit changes, choose one option:

    • Click Connect to configure OAuth for Git. Use your Git credentials for the commit, then click Save.

    • Click Save to use the credentials from the Git connector.

  4. Go to your branch in the Git repository. It now displays the author details beside the commit.

NOTE

Harness does not support OAuth authentication for Git providers that use vanity URLs.

Generate an OAuth access token with vanity URLs

Harness supports OAuth access tokens with vanity URLs for GitHub and GitLab.

GitHub

For GitHub, follow Configure OAuth for Git provider. Harness updates the configuration automatically.

GitLab

For GitLab, customers need to ensure that their Vanity URL is added to the OAuth application's redirect URI list. The OAuth application is set up by Harness, so customers will need to contact Harness Support to complete this process. They must provide their subdomain to have the Vanity URL whitelisted.

Example: If your subdomain is yourcompany.harness.io, the redirect URI would be:

https://yourcompany.harness.io/gateway/api/secret/oauth2/gitlab

Supported Vanity URL Format

Harness supports vanity URLs in the format https://<YOUR_SUBDOMAIN>.harness.io. The following combinations are invalid:

  1. https://<YOUR_SUBDOMAIN_1>.<YOUR_SUBDOMAIN_2>.harness.io

  2. https://app.harness.io/<YOUR_SUBDOMAIN>

Enforce OAuth for commits

You can enforce OAuth for commits pushed from Harness to your Git provider.

To enable this setting:

Navigate to Account SettingsGeneralDefault SettingGit ExperienceEnable OAuth for Commits.

If this setting is enabled but OAuth is not configured for your account, commits from Harness to Git fail.

To resolve this, configure OAuth for your Git provider before making changes.

Last updated

Was this helpful?