SonarCloud VSTS build - Missing projects

99 views
Skip to first unread message

pdco...@hotmail.co.uk

unread,
Jun 4, 2018, 5:38:15 AM6/4/18
to SonarQube
Hello,

I have integrated the SonarCloud plugin into our CI builds in VSTS. Everything has been working fine, we have been running out builds and collecting analysis. We use a leak period of previous_version to allow us to determine if the code for this version is releasable or not.

Recently, we have noticed that on the odd occasion the analysis decides to not pick up all the projects, so our LOCs drop, then when the next build runs through the missing project re-appears in the project, but because the code is essentially 'new' all the bugs/code smells that were in that project have now been added to our leak period. If I delete the analysis where the project was missing, the leak period still contains the 'old' bugs.

I have spent some time looking through the logs for the MSbuild step, as you might expect the log file for the CI build with the missing project is noticeably smaller than build with all projects included. The main difference I can see between the logs is that the 'full' build has the step

CreateProjectSpecificDirs:
Creating directory "E:\VNext4\_work\2\.sonarqube\conf\9".

Whereas the build with missing projects does not contain this.

Using:
Visual Studio Build Step 1.*
SonarCloud Plugin 1.*

I'm not sure if there is any more information I can include to help.

Thanks,
Pete

duncan.po...@sonarsource.com

unread,
Jun 4, 2018, 9:36:44 AM6/4/18
to SonarQube
Hello Pete,

A couple of questions:
* what sort of build agents are you using - hosted, or self-hosted?
* is it always the same project that is skipped, or does it vary?
* are the missing projects .NET Core projects or old-style projects?

The target CreateProjectSpecificDirs is in the SonarLint.Integration.targets build that is injected into the build by the SonarLint.Integration.ImportBefore.targets.
If the target isn't being run then either (1) the targets aren't being injected into the build correctly, or (2) the targets are being injected but the CreateProjectSpecificDirs target is being skipped for some reason.

If you configure the build to produce detailed output (add /v:detailed as an MSBuild command line argument in the build step) you'll be able to see from the log if it's (2) or not i.e. the target is injected but skipped.

There is a potential issue issue if multiple concurrent build jobs are being executed on the same build machine, as described in this Scanner for MSBuild issue (note that it's ok to use the /m switch to tell MSBuild to build a single solution using multiple processes: the issue occurs if there are multiple solutions being built and analysed in parallel).
However, I don't think this would occur in VSTS unless you are using self-hosted build agents, and have more than one build agent configured on the same machine.

Regards,
Duncan

pdco...@hotmail.co.uk

unread,
Jun 4, 2018, 11:31:55 AM6/4/18
to SonarQube
Hi Duncan,

- We are using self-hosted agents
- I am not too sure, but I think most of the time it is the same project(s)
- They are old style projects (.net 4.5)

Having read what you have said, I think it might possibly be because we have multiple agents running on the same machine. We have 5 agents set up and around 12 different SonarCloud projects that all have a development CI build and a master build. 
Would this problem you mentioned be if the same CI build is running on different agents or if any CI build is running at the same time? I don't really want to fall back to having just 1 agent as that means the builds would start to queue up quite often.

I will try running the same CI build through at the same time on different agents with the detailed flag on and see if I can start to replicate the issue on a regular basis.

Thanks for your help and recommendations,
Pete

duncan.po...@sonarsource.com

unread,
Jun 4, 2018, 12:14:45 PM6/4/18
to SonarQube
Hi Pete,

If you have multiple build agents on the same machine then the issue will occur even if the agents are all building different build definitions. However, you should be able to use the workaround documented here.

Regards,
Duncan

pdco...@hotmail.co.uk

unread,
Jun 5, 2018, 6:52:18 AM6/5/18
to SonarQube
Hi Duncan,

Thanks for the link. 

We are using SonarCloud to do our analysis, so we don't have SonarScanner for MSBuild installed at all... Do we need to install it? Can we just grab the target file from the .ZIP and place in our MSBuild folder or are we totally restricted because of using SonarCloud?

Thanks,
Pete

duncan.po...@sonarsource.com

unread,
Jun 5, 2018, 8:46:16 AM6/5/18
to SonarQube
Hi Pete,

The SonarCloud VSTS extension uses the Scanner for MSBuild internally when analysing MSBuild projects.

If you look on your agent machine you'll find a copy of Scanner and the relevant targets file. The location with be something like the following:

 C:\agent\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.2.0\classic-sonar-scanner-msbuild\Targets\SonarQube.Integration.ImportBefore.targets

Regards,
Duncan

aegisc...@gmail.com

unread,
Jun 5, 2018, 10:31:12 AM6/5/18
to SonarQube
Hello,

We have multiple on prem TFS build agents on a single server using TFS, instead of VSTS.     Would the multiple build agents on one sever for TFS still cause the issue with projects being dropped?  Is the workaround the same?

Thanks

duncan.po...@sonarsource.com

unread,
Jun 5, 2018, 12:30:44 PM6/5/18
to SonarQube
Hi aegisc...@gmail.com,

Yes, I think the same issue would occur with TFS (the build agent software is the same).
And yes, the workaround is the same.

Regards,
Duncan
Reply all
Reply to author
Forward
0 new messages