Increase the memory via the SONAR_SCANNER_OPTS environment variable when running the scanner from a zip file: export SONAR_SCANNER_OPTS="-Xmx512m" Then, assuming both the cacerts and Dockerfile are in the current directory, create the new image with a command such as: docker build -tag our-custom/sonar-scanner-cli. Create a Dockerfile with the following contents: FROM sonarsource/sonar-scanner-cliĬOPY cacerts /opt/java/openjdk/lib/security/cacerts v `pwd`/cacerts:/opt/java/openjdk/lib/security/cacerts \Īlternatively, you can create your own container that includes the modified cacerts file. Mount the cacerts file that you've prepared in your target container:.Assuming your certificate file is named mycert.cer and it's in your current local directory:īash -c 'cd /tmp/certs & keytool -keystore cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias mycert -file mycert.cer' Add your certificate to the exported cacerts file.entrypoint cat sonarsource/sonar-scanner-cli /opt/java/openjdk/lib/security/cacerts > cacerts Extract the cacerts file from OpenJDK from the sonarsource/sonar-scanner-cli image:ĭocker pull sonarsource/sonar-scanner-cli.If you need to configure a self-signed certificate for the scanner to communicate with your SonarQube instance, we recommend using the OpenJDK provided with the sonarsource/sonar-scanner-cli image. This is configured in sonar-project.properties as follows: sonar.projectBaseDir=/home/ftpdrop/cobol/project1 analysis begins from jenkins/jobs/myjob/workspace but the files to be analyzed are in ftpdrop/cobol/project1. If the files to be analyzed are not in the directory where the analysis starts from, use the sonar.projectBaseDir property to move analysis to a different directory. This folder must contain a sonar-project.properties file if sonar.projectKey is not specified on the command line.Īdditional analysis parameters can be defined in this project configuration file or through command-line parameters. The root folder of the project to analyze can be set through the sonar.projectBaseDir property since SonarScanner 2.4.Ex: sonar-scanner ttings=./myproject.properties The property ttings can be used to specify the path to the project configuration file (this option is incompatible with the sonar.projectBaseDir property). Ex: sonar-scanner -Dsonar.projectKey=myproject -Dsonar.sources=src1
The properties can be specified directly through the command line. If a sonar-project.properties file cannot be created in the root directory of the project, there are several alternatives: You'll find them filed under sonarqube-scanner/src. To help you get started, simple project samples are available for most languages on GitHub.
You can find full details on the C/C++/Objective-C language page.
Scanning projects that contain C, C++, or ObjectiveC code requires some additional analysis steps. To scan using the SonarScanner Docker image, use the following command: docker run \ Running SonarScanner from the Docker image Run the following command from the project base directory to launch analysis and pass your authentication token: sonar-scanner -Dsonar.login=myAuthenticationToken.If you need more debug information, you can add one of the following to your command line: -X, -verbose, or -Dsonar.verbose=true. You should get output like this: usage: sonar-scanner Verify your installation by opening a new shell and executing the command sonar-scanner -h ( sonar-scanner.bat -h on Windows). Add the $install_directory/bin directory to your path.
Update the global settings to point to your SonarQube server by editing $install_directory/conf/sonar-scanner.properties: #- Default SonarQube server We'll refer to it as $install_directory in the next steps.