- ALM used: Azure DevOps
- CI system used: Azure DevOps
- Scanner command used when applicable: not relevant
- Languages of the repository: not relevant
- Only if the SonarCloud project is public, the URL: private
- Error observed: See below
- Steps to reproduce: See below
- Potential workaround: See below
Hi,
Today I’ve added SonarQube Cloud tasks to a Azure DevOps pipeline that is executed on a self-hosted build agent. The first run failed with this error:
##[error]No agent found in pool <pool name> which satisfies the following demand: java. All demands: msbuild, visualstudio, java, Agent.Version -gtVersion 3.218.0
Seems like this demand comes from the SonarCloudAnalyze@4 task. See sonar-scanner-azdo/src/extensions/sonarcloud/tasks/SonarCloudAnalyze/v4/task.json at 259f6505e6815cf9ff480f0e9d4c4aa25dad17ff · SonarSource/sonar-scanner-azdo · GitHub
Why is this demand there? I do not need to have Java installed on the build agent because the SonarCloudPrepare@4 task already installs it, as can be seen in its log:
13:10:15.583 The JRE provisioning is a time consuming operation.
JRE provisioned: OpenJDK21U-jre_x64_windows_hotspot_21.0.9_10.zip.
If you already have a compatible Java version installed, please add either the parameter "/d:sonar.scanner.skipJreProvisioning=true" or "/d:sonar.scanner.javaExePath=<PATH>".
I’ve tested and confirmed this by adding a dummy “User-defined capability” named java in the agent’s pool settings. With that the pipeline did start and the SonarQube Cloud analysis worked fine.
The log of the SonarCloudAnalyze@4 task then showed that it used the Java from the prepare task:
13:15:05.187 Using Java found in Analysis Config: C:\windows\ServiceProfiles\NetworkService\.sonar\cache\39c5e23f3ce4d420663afba8ffde28034b72e2b3e240943dc2321bc1f912eef9\OpenJDK21U-jre_x64_windows_hotspot_21.0.9_10.zip_extracted\jdk-21.0.9+10-jre\bin\java.exe
So the SonarCloudAnalyze@4 task does indeed not need Java preinstalled. Why does it still demand it?