You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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
Copy file name to clipboardExpand all lines: cmd/kosli/attestSonar.go
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -27,26 +27,26 @@ type attestSonarOptions struct {
27
27
payloadSonarAttestationPayload
28
28
}
29
29
30
-
constattestSonarShortDesc=`Report a SonarCloud or SonarQube attestation to an artifact or a trail in a Kosli flow. `
30
+
constattestSonarShortDesc=`Report a SonarQube attestation to an artifact or a trail in a Kosli flow. `
31
31
32
32
constattestSonarLongDesc=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.
34
34
The results are parsed to find the status of the project's quality gate which is used to determine the attestation's compliance status.
35
35
36
36
The scan to be retrieved can be specified in two ways:
37
37
1. (Default) Using metadata created by the Sonar scanner. By default this is located within a temporary .scannerwork folder in the repo base directory.
38
38
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,
39
39
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.
40
40
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
42
42
provide the correct revision using the --sonar-revision flag. Kosli then finds the scan results for the specified project key and revision.
43
43
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.
45
45
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.
46
46
`+attestationBindingDesc
47
47
48
48
constattestSonarExample=`
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:
50
50
kosli attest sonar \
51
51
--name yourAttestationName \
52
52
--flow yourFlowName \
@@ -56,7 +56,7 @@ kosli attest sonar \
56
56
--api-token yourAPIToken \
57
57
--org yourOrgName \
58
58
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:
60
60
kosli attest sonar \
61
61
--name yourAttestationName \
62
62
--flow yourFlowName \
@@ -66,7 +66,7 @@ kosli attest sonar \
66
66
--api-token yourAPIToken \
67
67
--org yourOrgName \
68
68
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:
70
70
kosli attest sonar \
71
71
--name yourAttestationName \
72
72
--flow yourFlowName \
@@ -78,7 +78,7 @@ kosli attest sonar \
78
78
--api-token yourAPIToken \
79
79
--org yourOrgName \
80
80
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:
82
82
kosli attest sonar \
83
83
--name yourAttestationName \
84
84
--flow yourFlowName \
@@ -91,7 +91,7 @@ kosli attest sonar \
91
91
--api-token yourAPIToken \
92
92
--org yourOrgName \
93
93
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:
Copy file name to clipboardExpand all lines: docs.kosli.com/content/getting_started/attestations.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -195,6 +195,14 @@ Kosli CLI will also verify and report if the detected issue reference is found a
195
195
196
196
See [attest Jira issue to an artifact or a trail](/client_reference/kosli_attest_jira/) for usage details and examples.
197
197
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
+
198
206
### Custom
199
207
200
208
The above attestations are all "fully typed" - each one knows how to interpret its own particular kind of input.
Copy file name to clipboardExpand all lines: docs.kosli.com/content/integrations/sonar.md
+21-21Lines changed: 21 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,12 @@
2
2
title: Sonar
3
3
bookCollapseSection: false
4
4
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."
6
6
---
7
7
# Record Sonar scan results in Kosli
8
8
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.
11
11
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.
12
12
13
13
## Setting up in Kosli
@@ -18,66 +18,66 @@ After switching on the integration, you will be provided with a webhook and a se
18
18
19
19
## Setting up Sonar Webhooks
20
20
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.
22
22
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.
24
24
25
-
In [SonarCloud](https://sonarcloud.io/) or [SonarQube](https://sonarqube.org):
25
+
In [SonarQube Cloud](https://sonarcloud.io/) or [SonarQube Server](https://sonarqube.org):
26
26
27
27
### To create a global webhook:
28
28
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
31
31
- Create a new Webhook
32
32
- Add the Kosli webhook URL and secret provided
33
33
- Click Create
34
34
35
-

36
-

35
+

36
+

37
37
38
38
### To create a project-specific webhook:
39
39
40
40
- 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

48
48
49
49
## Setting up the SonarScanner
50
50
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.
52
52
53
53
These parameters can be passed to the scanner in three ways:
54
54
- As part of the sonar-project.properties file used in CI analysis
55
55
- As arguments to the scanner in your CI pipeline's YML file
56
56
```shell
57
-
- name: SonarCloud Scan
58
-
uses: sonarsource/sonarcloud-github-action@master
57
+
- name: SonarQube Scan
58
+
uses: SonarSource/sonarqube-scan-action@master
59
59
with:
60
60
args: >
61
61
-Dsonar.analysis.kosli_flow=<YourFlowName>
62
62
-Dsonar.analysis.kosli_trail=<YourTrailName>
63
63
```
64
64
- As arguments to the CLI scanner
65
65
```shell
66
-
$ sonarscanner \
66
+
$ sonar-scanner \
67
67
-Dsonar.analysis.kosli_flow=<YourFlowName> \
68
68
-Dsonar.analysis.kosli_trail=<YourTrailName>
69
69
```
70
70
71
71
72
72
### Scanner parameters:
73
73
-`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 '-').
75
75
-`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.
- 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).
79
79
-`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).
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>
91
91
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.
0 commit comments