Skip to content

Commit 0b985e7

Browse files
authored
Update sonar stuff in docs (#448)
* Add sonar attestationts to getting started docs * Update references to SonarCloud to SonarQube Cloud to match Sonar's new branding * Update screenshots for Sonar's new branding * Make references to SonarQube/SonarQube Cloud less clunky
1 parent 2784f95 commit 0b985e7

12 files changed

+45
-37
lines changed

cmd/kosli/attestSonar.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,26 @@ type attestSonarOptions struct {
2727
payload SonarAttestationPayload
2828
}
2929

30-
const attestSonarShortDesc = `Report a SonarCloud or SonarQube attestation to an artifact or a trail in a Kosli flow. `
30+
const attestSonarShortDesc = `Report a SonarQube attestation to an artifact or a trail in a Kosli flow. `
3131

3232
const attestSonarLongDesc = attestSonarShortDesc + `
33-
Retrieves results for the specified scan from SonarCloud or SonarQube and attests them to Kosli.
33+
Retrieves results for the specified scan from SonarQube Cloud or SonarQube Server and attests them to Kosli.
3434
The results are parsed to find the status of the project's quality gate which is used to determine the attestation's compliance status.
3535
3636
The scan to be retrieved can be specified in two ways:
3737
1. (Default) Using metadata created by the Sonar scanner. By default this is located within a temporary .scannerwork folder in the repo base directory.
3838
If you have overriden the location of this folder by passing parameters to the Sonar scanner, or are running Kosli's CLI locally outside the repo's base directory,
3939
you can provide the correct path using the --sonar-working-dir flag. This metadata is generated by a specific scan, allowing Kosli to retrieve the results of that scan.
4040
2. Providing the Sonar project key and the revision of the scan (plus the SonarQube server URL if relevant). If running the Kosli CLI in some CI/CD pipeline, the revision
41-
is defaulted to the commit SHA. If you are running the command locally, or have overriden the revision in SonarCloud/SonarQube via parameters to the Sonar scanner, you can
41+
is defaulted to the commit SHA. If you are running the command locally, or have overriden the revision in SonarQube via parameters to the Sonar scanner, you can
4242
provide the correct revision using the --sonar-revision flag. Kosli then finds the scan results for the specified project key and revision.
4343
44-
Note that if your project is very large and you are using SonarCloud's automatic analysis, it is possible for the attest sonar command to run before the SonarCloud scan is completed.
44+
Note that if your project is very large and you are using SonarQube Cloud's automatic analysis, it is possible for the attest sonar command to run before the SonarQube Cloud scan is completed.
4545
In this case, we recommend using Kosli's Sonar webhook integration ( https://docs.kosli.com/integrations/sonar/ ) rather than the CLI to attest the scan results.
4646
` + attestationBindingDesc
4747

4848
const attestSonarExample = `
49-
# report a sonarcloud attestation about a trail using Sonar's metadata:
49+
# report a SonarQube Cloud attestation about a trail using Sonar's metadata:
5050
kosli attest sonar \
5151
--name yourAttestationName \
5252
--flow yourFlowName \
@@ -56,7 +56,7 @@ kosli attest sonar \
5656
--api-token yourAPIToken \
5757
--org yourOrgName \
5858
59-
# report a sonarqube attestation about a trail using Sonar's metadata:
59+
# report a SonarQube Server attestation about a trail using Sonar's metadata:
6060
kosli attest sonar \
6161
--name yourAttestationName \
6262
--flow yourFlowName \
@@ -66,7 +66,7 @@ kosli attest sonar \
6666
--api-token yourAPIToken \
6767
--org yourOrgName \
6868
69-
# report a sonarcloud attestation for a specific branch about a trail using key/revision:
69+
# report a SonarQube Cloud attestation for a specific branch about a trail using key/revision:
7070
kosli attest sonar \
7171
--name yourAttestationName \
7272
--flow yourFlowName \
@@ -78,7 +78,7 @@ kosli attest sonar \
7878
--api-token yourAPIToken \
7979
--org yourOrgName \
8080
81-
# report a sonarqube attestation for a pull-request about a trail using key/revision:
81+
# report a SonarQube Server attestation for a pull-request about a trail using key/revision:
8282
kosli attest sonar \
8383
--name yourAttestationName \
8484
--flow yourFlowName \
@@ -91,7 +91,7 @@ kosli attest sonar \
9191
--api-token yourAPIToken \
9292
--org yourOrgName \
9393
94-
# report a sonarcloud attestation about a trail with an attachment using Sonar's metadata:
94+
# report a SonarQube Cloud attestation about a trail with an attachment using Sonar's metadata:
9595
kosli attest sonar \
9696
--name yourAttestationName \
9797
--flow yourFlowName \

docs.kosli.com/content/getting_started/attestations.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ Kosli CLI will also verify and report if the detected issue reference is found a
195195

196196
See [attest Jira issue to an artifact or a trail](/client_reference/kosli_attest_jira/) for usage details and examples.
197197

198+
### SonarQube scan results
199+
200+
You can report the results of a SonarQube Server or SonarQube Cloud scan to Kosli. Kosli will use the status of the scan's Quality Gate (passing or failing) to determine the compliance status.
201+
202+
These scan result can be attested in two ways:
203+
- Using Kosli's [webhook integration](/integrations/sonar) with Sonar
204+
- Using [Kosli's CLI](/client_reference/kosli_attest_sonar)
205+
198206
### Custom
199207

200208
The above attestations are all "fully typed" - each one knows how to interpret its own particular kind of input.

docs.kosli.com/content/integrations/sonar.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
title: Sonar
33
bookCollapseSection: false
44
weight: 340
5-
summary: "The results of SonarCloud and SonarQube scans can be tracked in Kosli trails. This integration involves setting up a Sonar webhook in Kosli and a corresponding webhook in SonarCloud or SonarQube. When you run a scan of your SonarCloud/SonarQube project, the webhook is triggered and the results of the scan are sent to Kosli."
5+
summary: "The results of SonarQube Server and SonarQube Cloud scans can be tracked in Kosli trails. This integration involves setting up a Sonar webhook in Kosli and a corresponding webhook in SonarQube. When you run a scan of your SonarQube project, the webhook is triggered and the results of the scan are sent to Kosli."
66
---
77
# Record Sonar scan results in Kosli
88

9-
The results of SonarCloud and SonarQube scans can be tracked in [Kosli trails](/getting_started/trails/).
10-
This integration involves setting up a Sonar webhook in Kosli and a corresponding webhook in SonarCloud or SonarQube. When you run a scan of your SonarCloud/SonarQube project, the webhook is triggered and the results of the scan are sent to Kosli.
9+
The results of SonarQube Server and SonarQube Cloud scans can be tracked in [Kosli trails](/getting_started/trails/).
10+
This integration involves setting up a Sonar webhook in Kosli and a corresponding webhook in SonarQube. When you run a scan of your SonarQube project, the webhook is triggered and the results of the scan are sent to Kosli.
1111
Some parameters must be passed to the Sonar scanner when it is run (e.g. the name of the Flow corresponding to the project, and the name of the trail the results should be attested to); these are sent with the scan results, and allow Kosli to determine the compliance status of the results and attest them to the correct trail/artifact.
1212

1313
## Setting up in Kosli
@@ -18,66 +18,66 @@ After switching on the integration, you will be provided with a webhook and a se
1818

1919
## Setting up Sonar Webhooks
2020

21-
You're now just a few steps away from connecting SonarCloud/SonarQube to Kosli.
21+
You're now just a few steps away from connecting SonarQube to Kosli.
2222

23-
Both SonarCloud and SonarQube provide two types of webhooks: global (which are triggered when any project in your organization is scanned) and project-specific (which are triggered by a scan for that project only). Kosli supports both types of webhooks.
23+
Both SonarQube Server and SonarQube Cloud provide two types of webhooks: global (which are triggered when any project in your organization is scanned) and project-specific (which are triggered by a scan for that project only). Kosli supports both types of webhooks.
2424

25-
In [SonarCloud](https://sonarcloud.io/) or [SonarQube](https://sonarqube.org):
25+
In [SonarQube Cloud](https://sonarcloud.io/) or [SonarQube Server](https://sonarqube.org):
2626

2727
### To create a global webhook:
2828

29-
- In SonarCloud: Go to your Organization, then Administration > Webhooks
30-
- In SonarQube: Go to Administration > Configuration > Webhooks
29+
- In SonarQube Cloud: Go to your Organization, then Administration > Webhooks
30+
- In SonarQube Server: Go to Administration > Configuration > Webhooks
3131
- Create a new Webhook
3232
- Add the Kosli webhook URL and secret provided
3333
- Click Create
3434

35-
![SonarCloud Global Webhook page](/images/sonarcloud_integration_global.png)
36-
![SonarQube Global Webhook page](/images/sonarqube_integration_global.png)
35+
![SonarQube Cloud Global Webhook page](/images/sonarqube-cloud-integration-global.png)
36+
![SonarQube Server Global Webhook page](/images/sonarqube-integration-global.png)
3737

3838
### To create a project-specific webhook:
3939

4040
- Go to the project you want to create a webhook for
41-
- Click on Administration (SonarCloud) or Project Settings (SonarQube) and go to Webhooks in the dropdown menu
41+
- Click on Administration (SonarQube Cloud) or Project Settings (SonarQube Server) and go to Webhooks in the dropdown menu
4242
- Create a new Webhook
4343
- Add the Kosli webhook URL and secret provided
4444
- Click Create
4545

46-
![SonarCloud Project Webhook page](/images/sonarcloud_integration_project.png)
47-
![SonarQube Project Webhook page](/images/sonarqube_integration_project.png)
46+
![SonarQube Cloud Project Webhook page](/images/sonarqube-cloud-integration-project.png)
47+
![SonarQube Server Project Webhook page](/images/sonarqube-integration-project.png)
4848

4949
## Setting up the SonarScanner
5050

51-
In order for Kosli to know where the scan results should be attested, certain parameters can be passed to the SonarScanner. Note that parameters cannot be passed with SonarCloud's Automatic Analysis - in this case, Kosli determines the relevant Flow and Trail as described below.
51+
In order for Kosli to know where the scan results should be attested, certain parameters can be passed to the SonarScanner. Note that parameters cannot be passed with SonarQube Cloud's Automatic Analysis - in this case, Kosli determines the relevant Flow and Trail as described below.
5252

5353
These parameters can be passed to the scanner in three ways:
5454
- As part of the sonar-project.properties file used in CI analysis
5555
- As arguments to the scanner in your CI pipeline's YML file
5656
```shell
57-
- name: SonarCloud Scan
58-
uses: sonarsource/sonarcloud-github-action@master
57+
- name: SonarQube Scan
58+
uses: SonarSource/sonarqube-scan-action@master
5959
with:
6060
args: >
6161
-Dsonar.analysis.kosli_flow=<YourFlowName>
6262
-Dsonar.analysis.kosli_trail=<YourTrailName>
6363
```
6464
- As arguments to the CLI scanner
6565
```shell
66-
$ sonar scanner \
66+
$ sonar-scanner \
6767
-Dsonar.analysis.kosli_flow=<YourFlowName> \
6868
-Dsonar.analysis.kosli_trail=<YourTrailName>
6969
```
7070

7171

7272
### Scanner parameters:
7373
- `sonar.analysis.kosli_flow=<YourFlowName>`
74-
- The name of the Flow relevant to your project. If a Flow does not already exist with the given name, it is created. If no Flow name is provided, the project key of your project in SonarCloud/SonarQube is used as the name (with any invalid symbols replaced by '-').
74+
- The name of the Flow relevant to your project. If a Flow does not already exist with the given name, it is created. If no Flow name is provided, the project key of your project in SonarQube is used as the name (with any invalid symbols replaced by '-').
7575
- `sonar.analysis.kosli_trail=<YourTrailName>`
76-
- The name of the Trail to attest the scan results. If a Trail does not already exist with the given name it is created. If no Trail name is provided, the revision ID of the Sonar project (typically defaulted to the Git SHA) is used as the name.
76+
- The name of the Trail to attest the scan results. If a Trail does not already exist with the given name it is created. If no Trail name is provided, the revision ID of the SonarQube project (typically defaulted to the Git SHA) is used as the name.
7777
- `sonar.analysis.kosli_attestation=<YourAttestationName>`
7878
- The name you want to give to the attestation. If not provided, a default name "sonar" is used. If using dot-notation (of the form `<YourTargetArtifact.YourAttestationName>`), either the artifact fingerprint or git commit is also required (see below).
7979
- `sonar.analysis.kosli_git_commit=<GitCommitSHA>`
80-
- The git commit for the attestation. If not provided the revision ID of the Sonar project is used (provided it has the correct format for a git SHA).
80+
- The git commit for the attestation. If not provided the revision ID of the SonarQube project is used (provided it has the correct format for a git SHA).
8181
- `sonar.analysis.kosli_artifact_fingerprint=<YourArtifactFingerprint>`
8282
- The fingerprint of the artifact you want the attestation to be attached to. Requires that the artifact has already been reported to Kosli.
8383
- `sonar.analysis.kosli_flow_description=<DescriptionOfYourKosliFlow>`
@@ -87,7 +87,7 @@ $ sonar scanner \
8787

8888
## Testing the integration
8989

90-
To test the webhook once configured, simply scan a project in SonarCloud or SonarQube. If successful, the results of the scan will be attested to the relevant Flow and Trail (and artifact, if applicable) as a sonar attestation. <br>
90+
To test the webhook once configured, simply scan a project in SonarQube. If successful, the results of the scan will be attested to the relevant Flow and Trail (and artifact, if applicable) as a sonar attestation. <br>
9191
If the webhook fails, check that you have passed the parameters to the scanner correctly, and that the trail name, attestation name and artifact fingerprint are valid.
9292

9393
## Live Example in CI system
-237 KB
Binary file not shown.
-254 KB
Binary file not shown.
241 KB
Loading
347 KB
Loading
190 KB
Loading
273 KB
Loading
-155 KB
Binary file not shown.

0 commit comments

Comments
 (0)