sonnar cloud issue

Raffaelllo's Avatar

Raffaelllo

20 Feb, 2021 05:48 PM

Hello. I`m geting this error om my pr check project. How do i update java in this context? Thanks.

INFO: ------------------------------------------------------------------------
The version of Java (1.8.0_221) you have used to run this analysis is deprecated and we stopped accepting it.
Please update to at least Java 11. You can find more information here: https://sonarcloud.io/documentation/upcoming/
ERROR:
The SonarScanner did not complete successfully
17:39:12.458 Post-processing failed. Exit code: 1
Command exited with code 1

  1. Support Staff 1 Posted by Feodor Fitsner on 21 Feb, 2021 08:49 PM

    Feodor Fitsner's Avatar

    Hi Raffaelllo,

    All JDKs are in “C:\Program Files\Java\jdk{version}” directory, so you can do, for example, this to enable JDK 15:

    init:
    - set PATH=C:\Program Files\Java\jdk15\bin;%PATH%
    
  2. 2 Posted by Raffa Cabo Frio on 21 Feb, 2021 09:21 PM

    Raffa Cabo Frio's Avatar

    Thanks. It worked!

  3. 3 Posted by Mario Toffia on 25 Feb, 2021 08:55 AM

    Mario Toffia's Avatar

    Hi Feodor,

    I've tried to do your solution above and can see that it executes it (in the build log)

    "Build started
    set PATH=C:\Program Files\Java\jdk15\bin;%PATH%
    ..."
    

    But it still complaints about the JDK (I'm using image "Visual Studio 2019") - what have I done wrong?

    "The version of Java (1.8.0_221) you have used to run this analysis is deprecated and we stopped accepting it.
    Please update to at least Java 11. You can find more information here: https://sonarcloud.io/documentation/upcoming"
    

    Cheers,
    Mario :)

  4. Support Staff 4 Posted by Feodor Fitsner on 25 Feb, 2021 02:31 PM

    Feodor Fitsner's Avatar

    Could you drop a link to the build please?

  5. 5 Posted by Mario Toffia on 25 Feb, 2021 02:43 PM

    Mario Toffia's Avatar

    Hi and thanks for the prompt reply! :) - Absolutely, here it is:
    current build - it builds my open source project FluentDocker on github.

    Cheers,
    Mario :)

  6. Support Staff 6 Posted by Feodor Fitsner on 25 Feb, 2021 08:42 PM

    Feodor Fitsner's Avatar

    Try adding where java and java --version before running sonnarcloud command?

  7. 7 Posted by Mario Toffia on 26 Feb, 2021 09:38 AM

    Mario Toffia's Avatar

    Hi Feodor,

    It outputs that it has Open JDK 15...

    openjdk 15.0.1 2020-10-20
    OpenJDK Runtime Environment (build 15.0.1+9-18)
    OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)
    

    I don't understand this...

    Here's my appveyor file:

    skip_non_tags: false  
    #test: off
    image: Visual Studio 2019  
    configuration: Release
    
    dotnet_csproj:  
      patch: true
      file: '**\*.csproj'
      version: '{version}'
      package_version: '{version}'
      assembly_version: '{version}'
      file_version: '{version}'
      informational_version: '{version}'
    
    init:  
      - set PATH=C:\Program Files\Java\jdk15\bin;%PATH%
    
    install:  
      - ps: Switch-DockerLinux
      - ps: dotnet tool install -g GitVersion.Tool
      - ps: dotnet tool install -g dotnet-format
      - ps: dotnet tool install -g dotnet-sonarscanner -v:m
    
    before_build:  
      - nuget restore
     # - ps: dotnet format --check --dry-run
      - ps: dotnet gitversion /l console /output buildserver
      - ps: where java
      - ps: java --version
      - ps: dotnet sonarscanner begin /d:sonar.host.url=https://sonarcloud.io /d:sonar.login=e220dd372506f00fe34923f011ea45f8568e9bcc /k:mariotoffia_FluentDocker /o:mariotoffia /v:"$env:APPVEYOR_BUILD_NUMBER" /d:sonar.cs.opencover.reportsPaths="./output/coverage.opencover.xml" /d:sonar.coverage.exclusions="**Tests*.cs"
      - ps: $env:good_to_deploy="true"
      - ps: if (Test-Path env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH) {echo "Not going to deploy because pull request."}
      - ps: if (Test-Path env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH) {$env:good_to_deploy="false"}
      - echo good_to_deploy=%good_to_deploy%
    
    build:  
      publish_nuget: true
      verbosity: minimal
    
    test_script:  
      - ps: dotnet test --settings coverletArgs.runsettings --filter TestCategory=CI -f netcoreapp3.1
    
    after_test:  
      - ps: dotnet sonarscanner end /d:sonar.login=e220dd372506f00fe34923f011ea45f8568e9bcc
    
    artifacts:  
      - path: '.\**\Release\*.nupkg'
        name: NuGet Packages
    
    deploy:  
      - provider: NuGet
        on:
          branch: master
          good_to_deploy: true
        api_key:
          secure: SvrLpeGG/sw6ymYYGzaMGfKIBKvR4DJChspymL2tz2RWwOGJQ3H9NVHrdXxOHn4j
    <pre><code></code>
    </pre>
    
  8. 8 Posted by Mario Toffia on 26 Feb, 2021 10:47 AM

    Mario Toffia's Avatar

    Hi again, moved the commands to the sonar "end" command and got the following:

    where java
    java --version
    openjdk 15.0.1 2020-10-20
    OpenJDK Runtime Environment (build 15.0.1+9-18)
    OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)
    dotnet sonarscanner end /d:sonar.login=e220dd372506f00fe34923f011ea45f8568e9bcc
    

    it is the

    dotnet sonarscanner end /d:sonar.login=e220dd372506f00fe34923f011ea45f8568e9bcc
    

    failing with:

    dotnet : ERROR: Error during SonarScanner execution
    At line:1 char:1
    + dotnet sonarscanner end /d:sonar.login=e220dd372506f00fe34923f011ea45 ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (ERROR: Error du...anner execution:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError


    ERROR: The version of Java (1.8.0_221) you have used to run this analysis is deprecated and we stopped accepting it. Please update to at least Java 11. You can find more information here: https://sonarcloud.io/documentation/upcoming/ INFO: Final Memory: 23M/289M INFO: ------------------------------------------------------------------------

    Cheers,
    Mario

  9. Support Staff 9 Posted by Feodor Fitsner on 26 Feb, 2021 09:31 PM

    Feodor Fitsner's Avatar

    Could it be sonar scanner is searching for JDK in machine-wide PATH variable. You can try changing it and remove path to JDK 8, something like:

    $env:path = $env:path.replace('C:\Program Files\Java\jdk1.8.0\bin;', '')
    [Environment]::SetEnvironmentVariable("PATH", $env:path, "Machine")
    
  10. 10 Posted by Mario Toffia on 01 Mar, 2021 08:51 AM

    Mario Toffia's Avatar

    Hi, thanks for the suggestion and for all you help Feodor.

    I've finally got it to work using this (if someone else stumbles into this problem).

    init:
      - set PATH=C:\Program Files\Java\jdk15\bin;%PATH%
      - set JAVA_HOME_11_X64=C:\Program Files\Java\jdk15
      - set JAVA_HOME=C:\Program Files\Java\jdk15
    

    Cheers,
    Mario :)

  11. Support Staff 11 Posted by Feodor Fitsner on 01 Mar, 2021 05:22 PM

    Feodor Fitsner's Avatar

    Oh, I completely forgot about JAVA_HOME variable! Thank you for sharing the solution!

  12. Feodor Fitsner closed this discussion on 01 May, 2021 09:03 PM.

Comments are currently closed for this discussion. You can start a new one.

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