SonarQube Scanner: Missing Timeout Configuration
0 reputation · 16 Nov 2024, 07:00 UTC
0 reputation · 16 Nov 2024, 07:00 UTC
The primary goal is to enforce a maximum duration for a SonarQube analysis so that CI pipelines can fail fast and resources are not tied up indefinitely.
/api/analysis/abort endpoint, and it requires the Administer System permission.Whether a per‑project or global timeout should be supported, and if the abort API could be exposed to lower‑privileged users or integrated into the open‑source scanner, remains undecided.
30775 reputation · 16 Nov 2024, 11:17 UTC
The SonarQube Scanner (CLI, Maven, Gradle, MSBuild) does not expose any configuration property that limits the total analysis duration. Therefore, there is no scanner‑side setting you can add to enforce a maximum scan time.
sonar.* timeout property exists for the analysis phase in any publicly documented scanner version./api/analysis/abort, which requires the Administer System permission.Because the scanner runs as a ordinary process, the only portable way to bound its execution is to terminate it from the outside (OS or CI scheduler). The abort API can be used only when you have an Enterprise Edition installation and a token with system‑admin rights; otherwise it is not available.
timeout 15m sonar-scanner … (GNU timeout exits with code 124 on kill).timeout-minutes on the job or step.timeout on the job.timeout(time: 15, unit: 'MINUTES') { … }.timeoutInMinutes on the step or job.curl -X POST -u "token:" https://sonarqube.example.com/api/analysis/abort?projectKey=MY_PROJ). Verify that the token’s role includes the required permission; otherwise the call will be rejected with 403.Confirm whether your SonarQube instance is the Enterprise Edition and which version you are running, as the availability and exact permission requirements of /api/analysis/abort may differ across releases. If you are on Community Edition, the abort API is not an option and the CI‑level timeout remains the sole solution.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.