Skip to main content

Azure Pipelines–SonarQube analysis

After moving our build agents from one server to another, one of the builds no longer worked. When looking at the logs, I noticed that the build failed almost immediatelly with the following error message:

No agent found in pool Azure Pipelines which satisfies the specified demands: java

And indeed when I took a look at the specific pipeline demands I could see that java was required. Turns out that the SonarQube analysis requires java installed on the build server to be able to execute. As the build server was a new clean install, nothing was installed yet.

Install Java OpenJDK

Time to fix that…

The license terms of the Oracle JDK has changed and updates are no longer free. Therefore I choose to install the Azul OpenJDK(download it here).

I used the MSI and walked through the installation wizard. After completing the setup I manually created the JAVA_HOME environment variable and set it to the bin  folder of the Zulu installation(e.g. C:\Program Files\Zulu\zulu-11\bin\)

Normally this last step is not required but for an unknown reason, the environment variable wasn’t created by the installer.

Rescan for capabilities

Now it is time to update the agent capabilities. To trigger a rescan, the agent should be restarted. The agents were running as windows services so I went to the services screen and restarted the specific services. After doing that, the environment variable was detected as part of the capabilities:

Unfortunately this didn’t solve the issue and when I tried to rerun the build it still failed with the same error message.

In the SonarQube documentation I found the following:

If you add a Windows Build Agent and install a non-oracle Java version on it, the agent will fail to detect a needed capability for the SonarQube Azure DevOps plugin. If you are sure that the java executable is available in the PATH environment variable, you can add the missing capability manually by going to your build agent > capabilities > user capabilities > add capability. Here, you can add the key, value pair java, and null which should allow the SonarQube plugin to be scheduled on that build agent. This Bug has been reported to the Microsoft Team with azure-pipelines-agent#2046 but is currently not followed up upon.

Add user capability

Let’s follow the suggestion mentioned above and add the capability ourselves:

  • Go to Project Settings –> Agent Pools. Select the pool that contains the agent.
  • Go to the agents tab and select the agent from the pool.
  • Go to the capabilities tab and click on the ‘+’ sign to add a user defined capability.
  • Enter ‘java’ in the name field and leave the value field empty. Click Add.

Repeat this process for every agent that you want to be able to run this build.

Popular posts from this blog

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.

Kubernetes–Limit your environmental impact

Reducing the carbon footprint and CO2 emission of our (cloud) workloads, is a responsibility of all of us. If you are running a Kubernetes cluster, have a look at Kube-Green . kube-green is a simple Kubernetes operator that automatically shuts down (some of) your pods when you don't need them. A single pod produces about 11 Kg CO2eq per year( here the calculation). Reason enough to give it a try! Installing kube-green in your cluster The easiest way to install the operator in your cluster is through kubectl. We first need to install a cert-manager: kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.5/cert-manager.yaml Remark: Wait a minute before you continue as it can take some time before the cert-manager is up & running inside your cluster. Now we can install the kube-green operator: kubectl apply -f https://github.com/kube-green/kube-green/releases/latest/download/kube-green.yaml Now in the namespace where we want t

DevToys–A swiss army knife for developers

As a developer there are a lot of small tasks you need to do as part of your coding, debugging and testing activities.  DevToys is an offline windows app that tries to help you with these tasks. Instead of using different websites you get a fully offline experience offering help for a large list of tasks. Many tools are available. Here is the current list: Converters JSON <> YAML Timestamp Number Base Cron Parser Encoders / Decoders HTML URL Base64 Text & Image GZip JWT Decoder Formatters JSON SQL XML Generators Hash (MD5, SHA1, SHA256, SHA512) UUID 1 and 4 Lorem Ipsum Checksum Text Escape / Unescape Inspector & Case Converter Regex Tester Text Comparer XML Validator Markdown Preview Graphic Color B