Azure DevOps hosted build “java” demanded capability not present

Hi @ajwgregg. Welcome to the community.

To answer your first question, Java is required on the build agent because the Sonar scanner and language plugins are written in Java and they run on the build agent.

The reason installing the OpenJDK didn’t fix your build is because of this bug in the Azure DevOps Windows build agent, which we can’t fix or work round in our extensions. I’ve just pinged Microsoft to ask about the status of the bug.

The discussions about the bug and possible fixes in the PR and community thread to are rather long so I’ll summarise the main points:

  • “Java” is the correct demand for Azure DevOps extensions that require Java to be installed on the agent. It doesn’t specifically mean the Oracle Java installation.
  • The Microsoft build agent is responsible for detecting the capabilities of the build agent. It should recognise different Java installations, and indeed it does so on Linux. However, there is a bug in the Microsoft agent detection code on Windows build agents and so it currently only recognises the commercial Oracle Java installation.
  • The bug only affects self-hosted Windows build agents, and manually adding a “Java” demand is a the workaround recommended by Microsoft.
  • There isn’t anything we can do in our extensions to work round the bug. The Azure DevOps demands/capabilities system does not provide a mechanism for declaring optional/conditional demands. If we change the demand from “Java” (e.g. to “java_home”) then we’ll break self-hosted Unix build agents. If we remove the demand then we’ll break Azure DevOps Server’s ability to allocate jobs to the correct agents.

I hope this helps explain the current position.Until the build agent bug is fixed I’m afraid the best option for self-hosted Windows agents is to use the workaround suggested by Microsoft.

2 Likes