.NET scan inside the Docker container

Hi Tom!
This is in fact what I’m doing currently (great minds think alike :wink: )!
I can say a bit more about my integration with Azure Pipelines with this approach:

  1. first I execute SonarQubePrepare on agent, that sets the SONARQUBE_SCANNER_PARAMS variable with all the params required (like branch name, pull request variables, authorization from Azure’ Service Connection etc.).
  2. I create the ‘intermediate’ docker image with all the sonarQube tooling (including Java11)
  3. (having the sonarqube scan execution stored as a script) I pass the SONARQUBE_SCANNER_PARAMS to docker run under exact same name, so dotnet sonarscanner begin and dotnet scanner end processes pick up most of the params automatically from this environment variable
  4. I capture the report-task.txt and copy it from the docker to the location on the build agent where the SONARQUBE_SCANNER_PARAMS defines the file to be, thanks to that…
  5. SonarQubePublish picks it and publishes the result, so I can have the QualityGate integration with the pipeline and pull request

This is most elegant solution I could find so far.
More than the performance/time I care of is the true result of the scan :wink: As I said, I was more afraid seeing that different sdk and different msbuild could be used for the original build and for the scan.

Hope it will help somebody in the future!
I’m also open for improving the way I configured that.

Take care!
Paweł

2 Likes