SONAR IS NOT WORKING

raffacabofrio's Avatar

raffacabofrio

03 Jun, 2024 06:27 PM

Hello, Im getting this error:

dotnet-sonarscanner end /d:"sonar.login=***"
SonarScanner for MSBuild 6.2
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
Calling the SonarScanner CLI...
Error: LinkageError occurred while loading main class org.sonarsource.scanner.cli.Main
java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/cli/Main has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 60.0
The SonarScanner did not complete successfully
17:12:31.538 Post-processing failed. Exit code: 1
Command exited with code 1

Here is my command line to run sonar inside app veyor ( After build script )

set JAVA_HOME=C:\Program Files\Java\jdk16
set PATH=%JAVA_HOME%\bin;%PATH%

dotnet tool install --global dotnet-sonarscanner

dotnet-sonarscanner begin /k:"SharebookBR_sharebook-backend" /d:"sonar.host.url=https://sonarcloud.io" /o:"sharebookbr" /d:"sonar.login=c9dcb2a05df9b6f3c8e5f2647cc31b9e99d65af4" /d:sonar.cs.opencover.reportsPaths=.\ShareBook\ShareBook.Test.Unit\coverage.xml /d:"sonar.pullrequest.key=%APPVEYOR_PULL_REQUEST_NUMBER%" /d:"sonar.pullrequest.branch=%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" /d:"sonar.pullrequest.base=%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%"

dotnet build .\ShareBook\ShareBook.sln --no-incremental -v minimal --configuration Release

dotnet test .\ShareBook\ShareBook.Test.Unit\ShareBook.Test.Unit.csproj /p:AltCover=true

dotnet-sonarscanner end /d:"sonar.login=***"

  1. Support Staff 1 Posted by Owen McDonnell on 04 Jun, 2024 09:54 PM

    Owen McDonnell's Avatar

    Nothing has changed in terms of JDK or dotnet since last image update so I'm not sure if anything has changed with your project. Or maybe you had SonarScanner pinned before?
    Apparently the new version (requires at JDK 17 at a minimum)[https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code...].
    Does the error still occur if you set your JAVA_HOME variable to that version?

  2. 2 Posted by raffacabofrio on 05 Jun, 2024 04:44 PM

    raffacabofrio's Avatar

    Hello Owen. Thanks for replying.

    Yes, I changed JDK to 17. But i got a new error now:

    set JAVA_HOME=C:\Program Files\Java\jdk17
    set PATH=%JAVA_HOME%\bin;%PATH%

    dotnet tool install --global dotnet-sonarscanner
    You can invoke the tool using the following command: dotnet-sonarscanner
    Tool 'dotnet-sonarscanner' (version '6.2.0') was successfully installed.

    dotnet-sonarscanner begin /k:"SharebookBR_sharebook-backend"
    /d:"sonar.host.url=https://sonarcloud.io" /o:"sharebookbr"
    /d:"sonar.login=c9dcb2a05df9b6f3c8e5f2647cc31b9e99d65af4"
    /d:sonar.cs.opencover.reportsPaths=.\ShareBook\ShareBook.Test.Unit\coverage.xml
    /d:"sonar.pullrequest.key=%APPVEYOR_PULL_REQUEST_NUMBER%"
    /d:"sonar.pullrequest.branch=%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%"
    /d:"sonar.pullrequest.base=%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%"
    SonarScanner for MSBuild 6.2
    Using the .NET Core version of the Scanner for MSBuild
    The format of the analysis property sonar.pullrequest.key= is invalid
    The format of the analysis property sonar.pullrequest.branch= is invalid
    The format of the analysis property sonar.pullrequest.base= is invalid
    Default properties file was found at
    C:\Users\appveyor\.dotnet\tools\.store\dotnet-sonarscanner\6.2.0\dotnet-sonarscanner\6.2.0\tools\netcoreapp3.1\any\SonarQube.Analysis.xml
    Loading analysis properties from
    C:\Users\appveyor\.dotnet\tools\.store\dotnet-sonarscanner\6.2.0\dotnet-sonarscanner\6.2.0\tools\netcoreapp3.1\any\SonarQube.Analysis.xml

    Here is the url of this build
    https://ci.appveyor.com/project/Sharebook/sharebook-backend/builds/49946132

  3. Support Staff 3 Posted by Owen McDonnell on 06 Jun, 2024 01:49 PM

    Owen McDonnell's Avatar

    It looks like you're using an assortment of APPVEYOR_PULL_REQUEST_* environment variables that don't exist because that build is cloning from a regular commit.

  4. 4 Posted by raffacabofrio on 06 Jun, 2024 02:12 PM

    raffacabofrio's Avatar

    It worked. Thanks.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac