Scanner command used when applicable: C:\WINDOWS\system32\cmd.exe /D /S /C ““C:\Program Files (x86)\apache-maven-3.6.3\bin\mvn.cmd” -f C:\agent\5\12\s\pom.xml package org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar”
Languages of the repository: Java
We are using Azure DevOps with On-Premise agents which runs behind a company proxy.
For almost all tasks and plugins, the proxy is bein used, but when we run SonarCloud analysis as a maven plugin, it is not using the proxy. The only way to make the maven plugin use the proxy, is adding the proxy settings as maven options to the maven task: Maven build and release task - Azure Pipelines | Microsoft Docs.
The disadvantage is that the settings need to be entered for every build that runs SonarCloud from Maven.
I tried the following options, but none of them seem to work:
As part of JAVA_OPTS environment variable
As part of MAVEN_OPTS environment variable
As part of SONAR_SCANNER_OPTS environment variable
As part of the maven settings.xml (in mavens conf folder)
As part of the users maven settings (in users .m2 folder)
Am I missing something, or is this a bug in the maven plugin?
While I was checking my logfiles for secrets I think I found my problem. I found out that my proxy settings in the MAVEN_OPTS environment variables were missing:
If I remove this setting from the build task, it can connect:
This option is set by default in the task when you add the task in an Azure DevOps pipeline, and by default you don’t see the value because that part is collapsed.
Although I would expect that the JAVA_OPTS and/or SONAR_SCANNER_OPTS should be enough.
Here is a part of the logfile: PartOfLog.txt (26.6 KB)
If you need more, is there a way I can send the logfile in private?
Hi @BMCP , thanks for the information. The log part you provided is fine. I would ask you to instead of removing the setting, setup the proxy configuration for MAVEN_OPTS like you did for JAVA_OPTS and SONAR_SCANNER_OPTS, resulting into something like this:
If this works, then remove the proxy settings from SONAR_SCANNER_OPTS and check if it still works. I want to understand better what is your problem trying to isolate it. Could you do that and tell us the results, please?
If I enter the same proxy settings in the Azure DevOps task, then it is running fine. But then every user in our organization that is using maven builds, have to add those settings to their build task.
To clarify, on the build agents, the MAVEN_OPTS environment variables do include those proxy settings, like the JAVA_OPTS and SONAR_SCANNER_OPTS . But the Maven build task in Azure DevOps contains the “-Xmx1024m” in “Set MAVEN_OPTS to” by default. So the MAVEN_OPTS environment variable on our build agent always gets overwritten by the Maven build task, or we have to clear that value for every build with maven.
So on the machine, the MAVEN_OPTS is configured like I did for JAVA_OPTS and SONAR_SCANNER_OPTS.
I removed the Set MAVEN_OPT to variable from the task, so the environment variables for MAVEN_OPTS with the same configuration as JAVA_OPTS is used. And I removed the SONAR_SCANNER_OPTS. Then the task is running fine.