I’m using Sonarqube Developer for most of my projects which are coded in PHP, but I also have a solution which is in VB.NET and C# (using .NET 8) and I would like to have it scanned too. I noticed that the CLI scanner does not work for .NET projects, so I headed to doc to see how it should be done. I ended up using the .NET scanner as described here : Adding SonarQube analysis to GitLab CI/CD
The example code for Gitlab CI does not work, it fails to install openjdk-17-jre:
$ apt-get install --yes openjdk-17-jre
[30](https://gitlab.mycompany.com/my-projects/dot-net/-/jobs/13394#L30)Reading package lists...
[31](https://gitlab.mycompany.com/my-projects/dot-net/-/jobs/13394#L31)Building dependency tree...
[32](https://gitlab.mycompany.com/my-projects/dot-net/-/jobs/13394#L32)Reading state information...
[33](https://gitlab.mycompany.com/my-projects/dot-net/-/jobs/13394#L33)E: Unable to locate package openjdk-17-jre
Am I doing something wrong ? If not, how can this work and where should I report a bug in the documentation ?
I’m pretty sure this is going to be unique to your environment. Linux distros can surely install a package called openjdk-17-jre (I just did so on an Ubuntu VM).
Can you tell me more about your environment? What version/flavor of Linux, etc…
Thanks for your answer, but I’m pretty sure it doesn’t have anything to do with my Linux distro, but more with the docker image provided in the documentation. My pipeline runs on a Linux host (Ubuntu 20.04.6), with a docker gitlab runner.
Here is what it looks like from the doc :
sonarqube-check:
image: mcr.microsoft.com/dotnet/core/sdk:latest
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- "apt-get update"
- "apt-get install --yes openjdk-17-jre"
- "dotnet tool install --global dotnet-sonarscanner"
- "export PATH=\"$PATH:$HOME/.dotnet/tools\""
- "dotnet sonarscanner begin /k:\"projectKey" /d:sonar.token=\"$SONAR_TOKEN\" /d:\"sonar.host.url=$SONAR_HOST_URL\" " #Replace "projectKey" with your project key
- "dotnet build"
- "dotnet sonarscanner end /d:sonar.token=\"$SONAR_TOKEN\""
allow_failure: true
only:
- merge_requests
- master
- main
- develop
It looks like openjdk-17-jre cannot be installed in mcr.microsoft.com/dotnet/core/sdk:latest
Is the doc incorrect at this point ? Is it something else I’m missing ?
But I think I have something here, it’s using “buster” debian release (your’s is using bookworm)… so possibly a cached image of mcr.microsoft.com/dotnet/sdk. I’ll see if I remove the cache or avoid using it.