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
Copy file name to clipboardExpand all lines: cmd/kosli/attestSonar.go
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ type attestSonarOptions struct {
24
24
projectKeystring
25
25
serverURLstring
26
26
revisionstring
27
-
maxRetriesint
27
+
maxWaitint
28
28
payloadSonarAttestationPayload
29
29
}
30
30
@@ -39,9 +39,9 @@ The scan to be retrieved can be specified in two ways:
39
39
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,
40
40
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.
41
41
If there are delays in the scan processing (either because the scanned project is very large, or because SonarQube is experiencing processing delays), it may happen that
42
-
the scan results are not available by the time the attest sonar command is executed. In this case you can use the ^--max-retries^ flag to retry the command while waiting for the scan to be processed.
43
-
This flag takes the maximum number of retries for the Kosli CLI to attempt to retrieve the scan results, with exponential backoff. Once the results
44
-
are available they are attested to Kosli as usual.
42
+
the scan results are not available by the time the attest sonar command is executed. In this case you can use the ^--max-wait^ flag to retry the command while waiting for the scan to be processed.
43
+
This flag takes the maximum number of seconds to wait for the results to be available. The Kosli CLI will then attempt to retrieve the scan results until the maximum wait time is reached, with
44
+
exponential backoff between retries. Once the results are available they are attested to Kosli as usual.
45
45
46
46
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
47
47
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
@@ -62,7 +62,7 @@ kosli attest sonar \
62
62
--api-token yourAPIToken \
63
63
--org yourOrgName \
64
64
65
-
# report a SonarQube Server attestation about a trail using SonarQube's metadata, allowing for up to 10 retries:
65
+
# report a SonarQube Server attestation about a trail using SonarQube's metadata, waiting for up to 60 seconds for the results to be available:
66
66
kosli attest sonar \
67
67
--name yourAttestationName \
68
68
--flow yourFlowName \
@@ -71,7 +71,7 @@ kosli attest sonar \
71
71
--sonar-working-dir yourSonarWorkingDirPath \
72
72
--api-token yourAPIToken \
73
73
--org yourOrgName \
74
-
--max-retries 10
74
+
--max-wait 60
75
75
76
76
# report a SonarQube Cloud attestation for a specific branch about a trail using key/revision:
77
77
kosli attest sonar \
@@ -98,7 +98,7 @@ kosli attest sonar \
98
98
--api-token yourAPIToken \
99
99
--org yourOrgName \
100
100
101
-
# report a SonarQube Cloud attestation about a trail with an attachment using SonarQube's metadata, allowing for up to 5 retries:
101
+
# report a SonarQube Cloud attestation about a trail with an attachment using SonarQube's metadata, waiting for up to 300 seconds for the results to be available:
Copy file name to clipboardExpand all lines: cmd/kosli/root.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -241,7 +241,7 @@ The ^.kosli_ignore^ will be treated as part of the artifact like any other file,
241
241
sonarProjectKeyFlag="[conditional] The project key of the SonarCloud/SonarQube project. Only required if you want to use the project key/revision to get the scan results rather than using Sonar's metadata file."
242
242
sonarServerURLFlag="[conditional] The URL of your SonarQube server. Only required if you are using SonarQube and not using SonarQube's metadata file to get scan results."
243
243
sonarRevisionFlag="[conditional] The revision of the SonarCloud/SonarQube project. Only required if you want to use the project key/revision to get the scan results rather than using Sonar's metadata file and you have overridden the default revision, or you aren't using a CI. Defaults to the value of the git commit flag."
244
-
sonarMaxRetriesFlag="[optional] Allow the command to retry fetching the scan results from SonarQube, up to the maximum number of retries provided, with exponential backoff. Useful when using SonarQube's metadata file to retrieve and attest scans that take a long time to process . Defaults to 0."
244
+
sonarMaxWaitFlag="[optional] Allow the command to wait and retry fetching the scan results from SonarQube, up to the maximum number of seconds provided, with exponential backoff. Useful when using SonarQube's metadata file to retrieve and attest scans that take a long time to process . Defaults to 30 seconds."
245
245
logicalEnvFlag="[required] The logical environment."
246
246
physicalEnvFlag="[required] The physical environment."
247
247
attestationTypeDescriptionFlag="[optional] The attestation type description."
logger.Info("retry %d: waiting %ds for SonarQube scan to be processed...", retries+1, wait)
248
248
time.Sleep(time.Duration(wait) *time.Second)
249
+
249
250
ifelapsed>300 { // If we've waited 5 minutes, we'll wait 300 seconds (5 minutes) before checking again. This is so that we don't end up with extremely long waiting intervals with the doubling approach.
0 commit comments