SonarScanner issue on AWS CodeBuild with .Net Core 2.1 Project

I’m attempting to integrate SonarQube into our CI/CD pipeline. I have a SonarQube 7.4 server setup which appears to be working fine. I can run a scan or my .Net Core 2.1 application using the instructions found at the following location without a problem.

https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild

I’m using AWS CodePipeline with AWS CodeBuild for my CI build process. The problem is that the SonarScanner does appear to be working using the CodeBuild container. The error I get is on the sonarscaner end.

The error log in AWS is shown below

Calling the SonarQube Scanner…
/root/.dotnet/tools/.store/dotnet-sonarscanner/4.4.2/dotnet-sonarscanner/4.4.2/tools/netcoreapp2.1/any/sonar-scanner-3.2.0.1227/bin/sonar-scanner: 59: exec: : Permission denied
The SonarQube Scanner did not complete successfully
08:53:50.666 Creating a summary markdown file…
08:53:50.666 Post-processing failed. Exit code: 1
[Container] 2018/11/23 08:53:50 Command did not exit successfully dotnet sonarscanner end /d:sonar.login=$SONARQUBE_LOGIN_TOKEN exit status 1
[Container] 2018/11/23 08:53:50 Phase complete: POST_BUILD Success: false
[Container] 2018/11/23 08:53:50 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: dotnet sonarscanner end /d:sonar.login=$SONARQUBE_LOGIN_TOKEN. Reason: exit status 1

I built the same docker image locally and get the exact same problem as I am doing running it in AWS. This can be found in GitHub at the following location:

To reproduce the problem I start the container interactively copy my source into the container using docker cp and the run the following commands

dotnet tool install --global dotnet-sonarscanner

dotnet sonarscanner begin /k:MyProjectCode /d:sonar.host.url=https://MySonarQubeServerInAWS /d:sonar.login=MyUserToken

dotnet build MyProject.sln

dotnet-sonarscanner end /d:sonar.login=MyUserToken

Everything works until I call the end command and I get the same error as above

Any help would be much appreciated

.

Thanks,

Rob

Hi,

I’m not a Windows user, but this error makes me wonder about execute permissions on the installed tool…

And/or does the process running analysis have read/write/execute in the analysis directory? Analysis needs to create a temp directory.

 
Ann

Thanks for the reply.

I finally figured the problem and it was nothing to do with permissions. I needed to include Java 8 in the container build. Once I did this everything work great.

Cheers,

Rob

1 Like

Thanks for the followup Rob!

Hi Rob, how did you do to include Java 8 in the container build? Cheers and I wait for you answer

Hi Alexis

Please find attached my docker build file which is just the AWS Code build image for .Net with Java added in.

You can find AWS CodeBuild docker images in GitHub at following location:

https://github.com/aws/aws-codebuild-docker-images

Hope this helps.

Cheers,

Rob

(Attachment Dockerfile is missing)

Hi Alexis

Please find attached my docker build file (renamed with txt extension so it doesn’t get rejected) which is just the AWS Code build image for .Net with Java added in.

You can find AWS CodeBuild docker images in GitHub at following location:

https://github.com/aws/aws-codebuild-docker-images

Hope this helps.

Cheers,

Rob

Dockerfile.txt (9.55 KB)

thank you for your help