Hello everyone,
I’m currently facing an issue and would really appreciate your help. Below is a detailed description of the problem:
Problem:
Last month, we added a large feature to our main branch. Since then, our pipeline task in Azure DevOps has stopped working. Interestingly, pull requests with smaller-scale changes still work fine.
Expected Behavior:
We have a limit of 500k lines of code (LoC). Before merging the feature, we used approximately 350k LoC. The new feature adds about 46k LoC, so it should still be well within the limit.
Actual Behavior:
Despite our calculations, the Publish Quality Gate Result task fails during execution with the following error message:
2024-12-02T14:29:22.9780048Z ##[section]Publish Quality Gate Result wird gestartet.
2024-12-02T14:29:22.9918204Z ==============================================================================
2024-12-02T14:29:22.9918273Z Task : Publish Quality Gate Result
2024-12-02T14:29:22.9918320Z Description : Publish SonarQube's Quality Gate result on the Azure DevOps build result, to be used after the actual analysis.
2024-12-02T14:29:22.9918383Z Version : 6.3.2
2024-12-02T14:29:22.9918410Z Author : sonarsource
2024-12-02T14:29:22.9918444Z Help : [More Information](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops/)
2024-12-02T14:29:22.9918521Z ==============================================================================
2024-12-02T14:30:27.2316714Z ##[warning]Error while executing SonarQube:Publish task: [SQ] Task failed with status FAILED, Error message: The last analysis failed because it would have caused your server-wide lines of code total to exceed your 500000 limit.
2024-12-02T14:30:27.2317582Z ##[error][SQ] Task failed with status FAILED, Error message: The last analysis failed because it would have caused your server-wide lines of code total to exceed your 500000 limit.
2024-12-02T14:30:27.2370522Z ##[section]Publish Quality Gate Result wird fertiggstellt
Environment Details
Here are some details about my setup that might be helpful:
SonarQube Server: Version 10.7 (zip installation)
Build Agent: Self-managed Windows 10 Virtual Machines (same behavior on both agents)
Pipeline Task: Version 6.3.2 (DevOps 19.225.35005.1)
Azure DevOps: Version 19.225.35005.1
Steps Taken to Troubleshoot
We have already tried the following steps, but the issue persists:
Updated the SonarQube Server from version 10.6 to 10.7.
Updated pipeline tasks from version 5.* to 6.*.
Reviewed source files for exclusions from analysis.
Verified the LoC calculations in VS2022 both before and after merging the feature.
Questions and Next Steps
Could there be a discrepancy in how LoC are calculated by SonarQube vs. our manual calculations?
Is there a specific configuration or setting we might have overlooked?
If you need any further information or logs, please let me know, and I will provide them as quickly as possible.
I did attache the SonarqubePrepare.log (9.6 KB) and removed all GUIDs and company related information. The analysis task log contains all our project names. I am not allowed to publish this information. Can you lead me in a specific direction, what you are looking for? Otherwise I have to X-out all names of 130 projects. Please let me know.
You also requested “(redacted) pipeline”. I can not freely publish all logs and I need to mention, it’s a classic pipeline. The only option i have, is to export yaml scripts for each task. I did upload a screenshot of the pipeline UI.
On the pipeline I would need the configuration of the Prepare Analysis task (an export to YAML, removing tokens and other security-sensitive information would be perfect, actually).
As for the log of the Analyze task, if you want you can send it by private message so it is not exposed here. I do not know what I am looking for to be honest, so it is difficult to guide you here.
I would send you the log file via private message, as you suggest, but it’s not possible, because I am a fresh user. If we find any hints, we can repost it here afterwards.
One question: When you say you added a large feature of about 46k LoCs, are you accounting for other languages that would be included in the project (as content for example)?
I’m thinking about large XML files, since this seems to be the only other language present in your project (usually 1 to 3 files, but one project has 24 and the other has 32).
if you talk about the TestAssets Namespace in toolsxbrl.core.test project, I can say, that my calculation don’t include this files in my calculation. I thought it doesn’t matter because it’s in a dedicated test project. Do you suggest, excluding them in the analysis scope:
It might be that, I’m not sure. If the scanner has trouble categorizing the project then they could be counted towards the LoCs.
There’s also the XML config files for UI things such as Ribbon config in the VSTO and FIRE.sys.net projects. No idea how big these are.
It seems, that the exclusion don’t work at all… I will investigate that first and get back to you, if i get further information. Thanks for pointing in the right direction.
After excluding the .xml files in the pipeline prepare task, it worked. In our setup the SonarQube UI for the webbrowser seems to have no effect at all.
#Your build pipeline references an undefined variable named ‘Parameters.projectKey’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See YAML schema reference | Microsoft Learn
#Your build pipeline references an undefined variable named ‘Parameters.projectKey’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
steps:
- task: sonarsource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@6
displayName: 'Prepare analysis on SonarQube'
inputs:
SonarQube: Sonar
projectKey: '$(Parameters.projectKey)'
projectName: 'Quality Check'
extraProperties: |
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
sonar.exclusions=**/*.bin,**/*.xml,**/*.xsd
sonar.vbnet.vscoveragexml.reportsPaths=**/*.coveragexml
sonar.verbose=true