TFS SonarQube tasks causes build agent to become disabled

Hi,

I have TFS 2017 with a build definition that executes successfully. I have a SonarQube server 7.9.1 and I also installed the latest TFS SonarQube extensions, so that now I have available the “Prepare analysis on SonarQube” , “Run Code Analysis” and “Publish Quality Gate Results” tasks.

I added “Prepare analysis…” and “Run Code Analysis” tasks to my build definition and configured the tasks successfully, also I defined a SonarQube Server EndPoint.

First I had an error saying that the build agent didn’t have the java capability; so I defined a system variable over the build agent server called “java” with a value of “C:\jdk-11.0.2\bin” (openJDK 11); and then I restarted the Agent; and then when I review the capabilities of the agent over TFS , it does show the java capability; so that now I don’t get the error of not having an agent with the java capability.

Now, when I have the SonarQube tasks enabled and submit a build request, I get: “Waiting for an enabled agent. All possible agents are disabled.” and remains like this forever, until I cancel the request.

But if I disable the SonarQube tasks, then the build executes successful.

does anyone know about this? have you seen this before?

Thanks,
Francisco.

Note: through TFS the agent appears online all the time and it is; but yet when enabling the SonarQube task as part of the build definition, I keep getting the message mentioned above of "Waiting for an enabled agent. All possible agents are disabled."

Hi,

What is your agent version installed ?

The agent version is 2.105.7

I did another test and got different results; I disabled the “Run Analysis” SonarQube Task and have enbabled only the “Prepare Analysis” Task, to see what happens, and this time the build definition started executing, but unsuccessful, the “Prepare Analysis” SonarQube task issued an error:

2019-10-10T15:16:14.5016380Z ##[error]Path must be a string. Received undefined

It turns out that the Path error relates to the variable “Agent.TempDirectory” not being defined; I added that variable and then the “Prepare Analysis” SonarQube task seems to execute successfully.

Then, I enabled back the “Run Analysis” SonarQube, to see if this times executes; but got the message:
"Waiting for an enabled agent. All possible agents are disabled."

So now, it looks like the cause of the above message is due to the “Run Code Analysis” task. This task does not have much configuration, other than the Timeout value with it is by default to ‘0’ (meaning infinitive timeout)

is there something I might be missing here?

I have been wondering about the Scanner, do i need to install a scanner at the build server? (my understanding was that the scanner using the latest SonarQube tasks was not required, in older versions of the task , there was a Scanner task which is now deprecated.)

For technical reasons, we had to define minimal agent versions to be able to run certain tasks.

As you said 2.105.7 on your side, for example the Run Analysis Task needs the 2.119.1 minimum.

So it may be worth updating your agent version on your side, if it’s possible of course.

Thanks.

Mickaël

Hi Mickael,

I tried updating the agent automatically through TFS 2017, but seems that it does not work.
Then I downloaded the agent through TFS and notice that the Agent version is 2.122.1, so I went ahead and installed another agent at the build server; so that now I have agent 2.105.7 and agent 2.122.1

Now, TFS shows those two agents available (different versions)

And tried again executing the Sonar Qube tasks (pre analysis, code analysis and publish gate tasks) and this time all executed successful through the second agent (2.122.1); it is working now.

then I went to the SonarQube server and was able to see the analysis result, everything seems to be working as expected.

Next for me will be to get deeper into SonarQube server for managing results, etc… if you know any documentation along that line, it would be helpful (also, how to fail the build in case that the quality gate did not pass?)

Thanks again,
Francisco.

You have a full house of documentation just here : https://docs.sonarqube.org/latest/

If you have any specific question, i suggest you to open a new thread with it.

And for the build breaker, we don’t have such feature, but there’s a 3rd party plugin which do so.

Mickaël

Ok, thanks for the information.

Francisco.