SonarScanner fails with error Permission denied

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- 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?



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


Thanks. This did not work.
I have already setting

chmod 777 sonar-scanner-

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

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.

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?

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.

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.

Thanks for lettings us know what was the problem!

@Viliam Can you please share what line did you add in pipeline. if i added
apk add openjdk8-jre it gives me apk is not a command

the message apk is not a command means you are likely running an operating system that does not come with apk as a package manager. There are likely many solutions based on your specific Operating System and configuration. try here for detailed answers related to your specific set up: