Github action failing for .NET framework build

Getting the following error

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 55.0

The SonarScanner did not complete successfully

18:33:35.512 Post-processing failed. Exit code: 1

My action YML is as follows

name: Build
on:
  push:
    branches:
      - AZU-Setup # or the name of your main branch

jobs:
  build:
    name: Build
    runs-on: windows-latest
    steps:
      - name: Set up JDK 11
        uses: actions/setup-java@v1
        with:
          java-version: 1.11
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: Cache SonarQube packages
        uses: actions/cache@v1
        with:
          path: ~\sonar\cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: Cache SonarQube scanner
        id: cache-sonar-scanner
        uses: actions/cache@v1
        with:
          path: .\.sonar\scanner
          key: ${{ runner.os }}-sonar-scanner
          restore-keys: ${{ runner.os }}-sonar-scanner
      - name: Install SonarQube scanner
        if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
        shell: powershell
        run: |
          New-Item -Path .\.sonar\scanner -ItemType Directory
          dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
      - name: Setup Nuget
        uses: Nuget/setup-nuget@v1.0.5
      - name: Restore nuget packages
        run: nuget restore **.sln
      - name: Add msbuild to PATH
        uses: microsoft/setup-msbuild@v1.1
      - name: Build and analyze
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
        shell: powershell
        run: |
          .\.sonar\scanner\dotnet-sonarscanner begin /k:"BrandPortal" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}"
          msbuild /t:Rebuild
          .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

Hi,

Welcome to the community!

This guide should help:

 
Ann

Unfortunately that doesn’t help in this instance since this is happing using GitHub Actions templates provided by SonarQube located on this page GitHub integration

Hi,

Thanks for pointing that out. I’ll make sure to get the docs corrected.

Where they have you explicitly pointing to Java 11:

You should instead use

java-version: '17'

 
HTH,
Ann

I think this was due to the docs not being on the latest version on my end.
The latest version GitHub integration does have the later java version.

Thanks!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.