SonarCloud Integration issue...!

Rakesh Krishan Prakash's Avatar

Rakesh Krishan Prakash

23 Aug, 2021 10:22 AM

Hi Team,

I am facing an issue while intigrating sonar. the error is attached. I followed all the steps as directed in the below link. But every time I am getting the same error. I am having JAVA 16 in my system.

Followed this link to step:- https://www.appveyor.com/blog/2016/12/23/sonarqube/

Please help and suggest.

Regards,
Rakesh Prakash

  1. Support Staff 1 Posted by Feodor Fitsner on 23 Aug, 2021 03:06 PM

    Feodor Fitsner's Avatar

    Hi Rakesh,

    Please add the following to your build configuration to resolve the issue: https://help.appveyor.com/discussions/problems/28963-sonnar-cloud-i...

  2. 2 Posted by Rakesh Krishan ... on 23 Aug, 2021 03:42 PM

    Rakesh Krishan Prakash's Avatar

    Hi Feodor,

    I followed the steps but had no luck. I have attached the YML and screenshot.
    Kindly look into it and suggest.

    Regards
    Rakesh Prakash

  3. Support Staff 3 Posted by Feodor Fitsner on 23 Aug, 2021 04:12 PM

    Feodor Fitsner's Avatar

    There is no C:\Program Files\Java\jdk-16.0.2 directory in the system, try using C:\Program Files\Java\jdk-16 instead.

  4. 4 Posted by Rakesh Krishan ... on 23 Aug, 2021 04:29 PM

    Rakesh Krishan Prakash's Avatar

    Hi Feodor,

    After changing it. I am getting this error. Kindly see the attached screenshot and YML file. Kindly suggest.

    Regards,
    Rakesh Prakash

  5. Support Staff 5 Posted by Feodor Fitsner on 23 Aug, 2021 04:57 PM

    Feodor Fitsner's Avatar

    OK, try using exactly the same solution that worked in the suggested article:

    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
    
  6. 6 Posted by Rakesh Krishan ... on 23 Aug, 2021 05:27 PM

    Rakesh Krishan Prakash's Avatar

    Hi Feodor,

    Same error. PFA YML file.

    ERROR: JAVA_HOME exists but does not point to a valid Java home
           folder. No "\bin\java.exe" file can be found there.
    The SonarScanner did not complete successfully
    17:25:12.528 Post-processing failed. Exit code: 1
    Command exited with code 1

  7. Support Staff 7 Posted by Feodor Fitsner on 23 Aug, 2021 05:28 PM

    Feodor Fitsner's Avatar

    Try using jdk-15, not jdk-16.

  8. 8 Posted by Rakesh Krishan ... on 23 Aug, 2021 05:39 PM

    Rakesh Krishan Prakash's Avatar

    HI Feodor,

    Same error after change to Java15. PFA YML file.
    ============================================================
    ERROR: JAVA_HOME exists but does not point to a valid Java home
           folder. No "\bin\java.exe" file can be found there.
    The SonarScanner did not complete successfully
    17:36:55.247 Post-processing failed. Exit code: 1
    Command exited with code 1
    ==========================================================
    Can you please confirm is "choco install "sonarscanner-msbuild-net46" -y" is supportable to above Java 11

  9. Support Staff 9 Posted by Feodor Fitsner on 23 Aug, 2021 05:43 PM

    Feodor Fitsner's Avatar

    OK, I've noticed you configure project on UI. Try defining those variables on UI then, like in attached screenshot.

  10. 10 Posted by Rakesh Krishan ... on 23 Aug, 2021 05:52 PM

    Rakesh Krishan Prakash's Avatar

    Hi Feodor,

    I did the changes. But no success. PFA YML file.

    My project name is: dotnetcore2 , it is a dotnet core project

    Calling the TFS Processor executable...
    The TFS Processor has finished
    Calling the SonarScanner CLI...
    ERROR: JAVA_HOME exists but does not point to a valid Java home
           folder. No "\bin\java.exe" file can be found there.
    The SonarScanner did not complete successfully
    17:49:06.069 Post-processing failed. Exit code: 1
    Command exited with code 1

  11. Support Staff 11 Posted by Feodor Fitsner on 23 Aug, 2021 05:54 PM

    Feodor Fitsner's Avatar

    OK, before calling sonar CLI try calling:

    echo %JAVA_HOME%
    dir %JAVA_HOME%\bin
    
  12. Support Staff 12 Posted by Feodor Fitsner on 23 Aug, 2021 05:55 PM

    Feodor Fitsner's Avatar

    Could you drop me a link to the build please?

  13. 13 Posted by Rakesh Krishan ... on 23 Aug, 2021 06:00 PM

    Rakesh Krishan Prakash's Avatar

    Hi Feodor,

    PF the below-requested URL

    https://ci.appveyor.com/project/RakeshPrakash/dotnetcore2/builds/40489939

    ===========================================
    All projects are up-to-date for restore.
    echo %JAVA_HOME%
    C:\Program Files\Java\jdk-15
    dir %JAVA_HOME%\bin
    The system cannot find the path specified.
    Command exited with code 1
    ==================================

  14. Support Staff 14 Posted by Feodor Fitsner on 23 Aug, 2021 06:05 PM

    Feodor Fitsner's Avatar

    Oh, it must be jdk15, not jdk-15 (no dash)! Initial suggestion has correct path: https://help.appveyor.com/discussions/problems/28963-sonnar-cloud-i...

  15. 15 Posted by Rakesh Krishan ... on 23 Aug, 2021 06:39 PM

    Rakesh Krishan Prakash's Avatar

    Thanks, Feodor. The is issue is resolved.

    Now there is new issue which is when the sonar quality gate fails the build should also fail. but the build is successfully created. Any suggestions on this.

    Regards,
    rakesh prakash

  16. Support Staff 16 Posted by Feodor Fitsner on 23 Aug, 2021 06:41 PM

    Feodor Fitsner's Avatar

    Could you drop a link to a build please?

  17. 17 Posted by Rakesh Krishan ... on 23 Aug, 2021 07:27 PM

    Rakesh Krishan Prakash's Avatar
  18. Support Staff 18 Posted by Feodor Fitsner on 23 Aug, 2021 07:45 PM

    Feodor Fitsner's Avatar

    SonarScanner.MSBuild.exe should be the last in a command batch to pass its exit code to the build agent. Currently, you have dotnet publish. To fix that switch to using appveyor.yml in the repo where you can separate commands, like this:

    ...
    before_package:
    - choco install "sonarscanner-msbuild-net46" -y
    - SonarScanner.MSBuild.exe begin /k:"Dotnetcore2" /d:"sonar.host.url=https://sonarcloud.io" /o:"rpprimus" /d:"sonar.login=c86fe6180971df694383ad1e8b7a58ba8c5a91dc"
    - msbuild /verbosity:quiet "CompanyManagement.sln"
    - SonarScanner.MSBuild.exe end /d:"sonar.login=c86fe6180971df694383ad1e8b7a58ba8c5a91dc"
    - dotnet publish ./CompanyManagement/CompanyManagement.csproj
    
  19. 19 Posted by Rakesh Krishan ... on 24 Aug, 2021 08:35 AM

    Rakesh Krishan Prakash's Avatar

    hi feodor,

    Suggested changes have been done. But facing same.

    PFA YML file.

    Regards,
    Rakesh

  20. Support Staff 20 Posted by Feodor Fitsner on 24 Aug, 2021 01:36 PM

    Feodor Fitsner's Avatar

    Could you drop me a link to a build with sonar failing?

  21. 21 Posted by Rakesh Krishan ... on 24 Aug, 2021 01:42 PM

    Rakesh Krishan Prakash's Avatar

    Hi Feodor,

    Here is link of Sonar. In this I have defined the Quality gates and based on the Quality gates, the build should fail when any of the conditions do not meet. This can be achieved through Quality gate build breaker which needs to be defined in CI. And for CI we are using Appveyor. This functionality is available in all other CI tools such as Azure devops, Jenkins, Git CI, etc. But I cannot see this for Appveyor. Do we have this?

    https://sonarcloud.io/dashboard?id=Dotnetcore2

Reply to this discussion

Internal reply

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

Attaching KB article:

»

Already uploaded files

  • ScreenHunter_58_(01).png 17.9 KB
  • log_(1).txt 15.7 KB

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