Setting up a GitHub App
Setting up a GitHub App for use with SonarQube Community Build.
You need to use a GitHub App to connect SonarQube Community Build with a GitHub instance in order to use the following features:
Importing your GitHub repositories into SonarQube Community Build.
You need the global Administer System permission in SonarQube Community Build to perform this setup.
Setup overview
The setup consists of three stages:
Create or register a GitHub App — two methods are available:
Create configuration: You register and configure the app on GitHub yourself, then enter the credentials in SonarQube Community Build. Use this path if your network configuration prevents the automatic flow or if you already have a GitHub App you want to reuse.
Create app for me (recommended): SonarQube generates a preconfigured app and redirects you to GitHub to authorize its creation. SonarQube saves the resulting credentials automatically. Organization Owners complete the installation directly. Organization Members can initiate the flow, but an Owner must approve the installation to complete it.
Install the app on the GitHub organizations that SonarQube Community Build needs to access.
Create a GitHub App automatically
When you choose Create app for me, SonarQube creates the GitHub App with the required settings and permissions, and saves the credentials in SonarQube Community Build automatically.
Prerequisite
You need a GitHub account with an organization Owner or Member role. If you are an organization Owner, you can create and install the app in one step. If you are an organization Member, GitHub sends an installation approval request to your organization Owners. The app is active in SonarQube Community Build once an Owner approves it.
To create a GitHub App automatically:
In the SonarQube UI, go to Administration > Configuration > General Settings > DevOps Platform Integrations.
Open the GitHub tab and select Create app for me. Your window will open in GitHub to continue.
In GitHub, enter your GitHub organization and a unique Configuration name.
Optionally, select Also set up GitHub authentication to enable users to sign in using their GitHub login credentials.
Select Continue to GitHub to confirm access, after which the Create GitHub App page will open.
Add your GitHub App name and select Create GitHub App for Your GitHub Organization to continue. You can always change the app name later.
A new page will open where you must select the GitHub organization where you want to install the app.
Select either All repositories or Only select repositories to bind to SonarQube Community Build.
To complete the installation, select Install & Authorize to finish. GitHub will redirect you back to SonarQube Community Build. The App ID, Client ID, Client Secret, and Private Key are saved automatically in a new GitHub Configuration record.
SonarQube pre-configures the app with the following permissions, which are shown on GitHub for review:
Read access to administration, code, members, metadata, organization administration, and organization projects.
Read and write access to checks.
Read access to email addresses (user permission).
After the app is created, install it on your GitHub organizations.
If the automatic flow fails
If the automatic flow fails (for example, because of network or firewall restrictions between SonarQube Community Build and GitHub), use the manual setup instead. See Create a GitHub App manually.
Create a GitHub App manually
Use manual setup if:
Your SonarQube Community Build cannot complete the automatic flow (for example, because of network or firewall restrictions).
You already have a GitHub App for SonarQube Community Build and want to reuse it.
If you already have a GitHub App, skip the registration steps below and go directly to Add the GitHub App to SonarQube Community Build's global setup.
After registering a new app, continue with Install the GitHub App in your organizations.
See GitHub's documentation on registering a GitHub App for general information on GitHub Apps.
We recommend registering a public App. You can register a private App if you have only one GitHub organization. In that case, you must register the App under that organization.
Specify the following settings in your app:
GitHub App Name: Your app's name. Example: sonarqubeserver.
Homepage URL: Your SonarQube Community Build instance's base URL (for information purposes only).
Callback URL: Your SonarQube Community Build instance's base URL (the URL used to redirect to the SonarQube Community Build).
Webhook URL: To improve security, webhooks, by default, are not allowed to point to the SonarQube Community Build. Therefore, we recommend that you disable the feature. To disable the feature, clear the Webhook Active checkbox to silence a forthcoming deprecation warning, and clear the Webhook URL and Webhook secret fields.
Under Permissions and Subscribe to events, set up the permissions and events as explained below in the list of settings. Some permissions or events are only necessary depending on the purpose of the integration.
Permissions and events settings
Repository permissions
Administration
Read-only
Required only for user provisioning.
Checks
Read & Write
Contents
Read-only
In GitHub Enterprise Server: Repository metadata
In GitHub.com: Metadata
Read-only
Organization permissions
Administration
Read-only
Required only for user provisioning.
Members
Read-only
Projects
Read-only
Account permissions
Email addresses
Read-only
Required only for user authentication and provisioning.
Under Where can this GitHub App be installed? select Any account to make the App public in order to allow you to install the App on any organization.
After registering the app, install it on your GitHub organizations.
Install the GitHub App in your organizations
Install the GitHub App on each GitHub organization that SonarQube Community Build needs to access. See GitHub's documentation on installing GitHub Apps for more information.
Add the GitHub App to SonarQube Community Build's global setup
If you chose Create app for me, SonarQube has already created a GitHub Configuration record for repository import. You only need to complete this step if you used the manual setup, or if you want to set up user authentication delegation.
If you want to support the GitHub repository import
To add the GitHub App to SonarQube Community Build's global setup for repository import:
In the SonarQube UI, go to Administration > Configuration > General Settings > DevOps Platform Integrations.
Select the GitHub tab and select Create configuration. The Create a configuration dialog opens.
Specify the settings in the Configuration settings section below.
If you want to delegate the user authentication to GitHub
To add the GitHub App to SonarQube Community Build's global setup for user delegation, go to Administration > Configuration > General Settings > Authentication > GitHub. See Connecting your GitHub App to SonarQube Community Build in GitHub.
Configuration settings
Field
Description
Note
GitHub API URL
The API URL of the GitHub instance. For example, https://github.company.com/api/v3 for GitHub Enterprise or https://api.github.com/ for GitHub.com.
GitHub App ID
The App ID of your GitHub App (on GitHub, go to Settings > Developer Settings > GitHub Apps to view your App).
Client ID
The Client ID of your GitHub App's page.
Client Secret
The Client secret of your GitHub App's page. Administrators can encrypt this secret, see Sensitive settings.
Private Key
Your GitHub App's private key in PEM format. You can generate a .pem file from your GitHub App's page under Private keys. Copy and paste the whole contents of the file here.
Administrators can encrypt this key, see Sensitive settings.
Last updated
Was this helpful?

