Skip to content

Commit 4c4eaf6

Browse files
committed
update readme
1 parent 72fefa5 commit 4c4eaf6

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

plugins/sonarqube-issues/README.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,41 @@ info:
2727
This plugin requires a proxy to SonarQube. To set up:
2828
2929
- Create a token in SonarQube by clicking on your profile > My Account > Security
30-
- In Cortex, define a secret whose value is your new token. Name it `sonarqube_plugin`.
30+
- In Cortex, define a secret whose value is your new token. Name it `sonarqube_secret`.
3131
- Create a proxy:
3232

3333
- Navigate to Plugins, then click on the Proxies tab, then click on Create Proxy
3434
- Give the proxy a name, then click on Add URL
35-
- For the URL Prefix, type in the base URL of your SonarQube instance. Default for cloud is `https://sonarcloud.io`. **This URL prefix should be exactly the same as the value of the baseURL variable in [SonarqubeIssues.tsx](src/components/SonarqubeIssues.tsx) - If you are self-hosting SonarQube, you will have to put your own base URL in both places!**
36-
- Click on Add Header and add a header whose name is `Authorization` and whose value is `Bearer {{secrets.sonarqube_plugin}}` (include the curly braces!)
35+
- For the URL Prefix, type in the API base URL of your SonarQube instance. Default for cloud is `https://sonarcloud.io`. If you are self-hosting SonarQube, you will have a different API base URL.
36+
- Click on Add Header and add a header whose name is `Authorization` and whose value is `Bearer {{secrets.sonarqube_secret}}` (include the curly braces!)
3737

3838
- Once you are done, the proxy should look like the below:
3939

4040
<div align="center"><img src="img/sonarqube-proxy.png"></div>
4141

42+
### Self-Hosted setup
43+
44+
The plugin uses `https://sonarcloud.io` as its default API base URL. If you are self-hosting Sonarqube, then you will have a different URL. To configure the plugin to use that URL, you can create a Sonarqube plugin configuration entity in Cortex with your own API base URL.
45+
46+
- Consider creating a new entity type, so that any existing scorecards are not affected by ths configuration entity. In this example, we have created a new entity type called `plugin-configuration`
47+
- Create a new entity with the tag `sonarqube-plugin-config`
48+
- Set `x-cortex-definition.sonarqube-api-url` to the value of your ServiceNow Instance URL. For example, if my Sonarqube API base URL was `https://sonarqube.martindstone.com`, my `sonarqube-plugin-config` entity would look like this:
49+
50+
```yaml
51+
openapi: 3.0.1
52+
info:
53+
title: Sonarqube Plugin Config
54+
description: ""
55+
x-cortex-tag: sonarqube-plugin-config
56+
x-cortex-type: plugin-configuration
57+
x-cortex-definition:
58+
sonarqube-api-url: https://sonarqube.martindstone.com
59+
```
60+
4261
Now, you can build and add the plugin.
4362

4463
- Build the plugin:
45-
- Make sure you have npm/yarn, and make sure you have put in your correct SonarQube Base URL in the baseURL variable in [SonarqubeIssues.tsx](src/components/SonarqubeIssues.tsx)
64+
- Make sure you have npm/yarn
4665
- In your terminal, in the `sonarqube-issues` directory, type `yarn` or `npm install` to install the dependencies; then type `npm run build` or `yarn build` to build the plugin
4766
- The compiled plugin will be created in `dist/ui.html`
4867
- In Plugins > All, click **Register Plugin**
@@ -55,12 +74,7 @@ Now, you can build and add the plugin.
5574

5675
Now, when you navigate to a Service that has a SonarQube associated with it, you should be able to click on Plugins > SonarQube Issues and see the SonarQube Issues associated with the project that is linked to the service.
5776

58-
**Note: This plugin will connect to SonarQube's cloud instance out of the box.** If you are self-hosting SonarQube and need to direct the plugin to a different API endpoint, update the following section of the [SonarqubeIssues.tsx](src/components/SonarqubeIssues.tsx) file:
59-
60-
```ts
61-
// Set your SonarQube url. Cloud is https://sonarcloud.io
62-
const baseURL = "https://sonarcloud.io";
63-
```
77+
**Note: This plugin will connect to Sonarqube's cloud API service out of the box.** If you are self-hosting SonarQube and need to direct the plugin to a different API base URL, make sure you follow the **Self-hosted setup** instructions above.
6478

6579
## Troubleshooting
6680

plugins/sonarqube-issues/src/components/SonarqubeIssues.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ const SonarqubeIssues: React.FC<SonarqubeIssuesProps> = ({ entityYaml }) => {
3939
}
4040
const getSonarqubePluginConfig = async (): Promise<void> => {
4141
setIsLoading(true);
42-
let newSnowUrl = "https://sonarcloud.io";
42+
let newApiBaseUrl = "https://sonarcloud.io";
4343
try {
4444
const response = await fetch(
4545
`${apiBaseUrl}/catalog/sonarqube-plugin-config/openapi`
4646
);
4747
const data = await response.json();
48-
newSnowUrl = data.info["x-cortex-definition"]["sonarqube-api-url"];
48+
newApiBaseUrl = data.info["x-cortex-definition"]["sonarqube-api-url"];
4949
} catch (e) {}
50-
setSonarqubeApiBaseUrl(newSnowUrl);
50+
setSonarqubeApiBaseUrl(newApiBaseUrl);
5151
setIsLoading(false);
5252
};
5353
void getSonarqubePluginConfig();

0 commit comments

Comments
 (0)