SonarScanner fails with error Permission denied

permissions

(Viliam) #1

Hi, I have installed SonarScanner for MSBUILD and running it in Bitbucket pipeline.
When I run sonar scanner with “end” parameter, it shows error below:

SonarScanner for MSBuild 4.3.1Using the .NET Core version of the Scanner for MSBuild
Default properties file was found at /opt/atlassian/pipelines/agent/build/sonar/SonarQube.Analysis.xml
Loading analysis properties from /opt/atlassian/pipelines/agent/build/sonar/SonarQube.Analysis.xml
Post-processing started.SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
Calling the SonarQube Scanner…/opt/atlassian/pipelines/agent/build/sonar/sonar-scanner-3.2.0.1227/bin/sonar-scanner: exec: line 66: : Permission denied
The SonarQube Scanner did not complete successfully12:12:25.915 Creating a summary markdown file…
12:12:25.915 Post-processing failed. Exit code: 1`

I’m not sure what permission it requires, given that I’m setting sonar.login and sonar.password variables and I can login successfully to the server with the credentials. I also run sonar-scanner begin and dotnet build command - all passes well.

I’m running server in AWS - I have used image created there.

Can you please advise?

Thanks

viliam


(Amaury Levé) #2

Hi @Viliam,

If you are running the scanner from a Unix machine, it happens that sometimes you need to grant permission on the script file.

  1. Locate the scanner folder
  2. Go to the sub-folder sonar-scanner-/bin
  3. chmod +x sonar-scanner

Cheers,
Amaury


(Viliam) #3

Thanks. This did not work.
I have already setting

chmod 777 sonar-scanner-3.2.0.1227/bin/sonar-scanner

please note that execution works with “begin” command, but fails with “end” command.


(Duarte Meneses) #4

Hi @Viliam,

Just to verify that you have a working sonar-scanner, could you please execute directly the sonar-scanner with the same user and see if it runs (if you get an error about missing properties, that’s fine)?
Note that sonar-scanner only runs in the “end” command.

From the error message I would agree with @Ammo that the problem with the permissions is related to the FS, not to login in SonarQube.


(Viliam) #5

HI
I have tried this from windows and it all worked perfectly fine. However I’m running this on bitbucket pipeline and have issue with the security.
I can see form the log that it launches on begin - so it feels that it can run. But I suspect that end command needs access somewhere or create cache or something and it fails on that…
There is no debug info I can see…
any other advice?


(Viliam) #6

Actually, I think I know where the problem is. I likely do not have java installed in the bitbucket .netcore image. I need to install it, just don;t know how.


(Viliam) #7

Actually - I have fixed it. I really did nto have Java - so I did simple apk add openjdk8-jre and that has fixed it.
at the end of the day, it was simple.

Thanks a lot for your help.


(Amaury Levé) #8

Thanks for lettings us know what was the problem!