How to filter files in sonar SCM? - jenkins

I have installed a CI environment for my PHP project.
I use jenkins + sonar + Gitlab.
All things seem great until build a jenkins job.
The error info is
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 2:03.218s
Final Memory: 345M/456M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: Unable to blame file src/apps/conf.php. No blame info at line 1. Is file commited?
10:21:17.165 INFO - Author: PersonIdent[Not Committed Yet, , Wed Feb 4 10:21:17 2015 +0800]
ERROR:
I find sonar SCM-Activity-Plugin report this bug.
The conf.php file is my config file and can not push to Gitlab.
So, Is there a way to ask SCM-Activity-Plugin filter these config files?
thanks a lot!

Excluding the file from sonar analysis might help.
Login to sonar using admin or user that have got administrative rights in the project.
Open the project and select “Settings” from “Project Configuration”.
There click on “Exclusions” link and take “File” tab.
Under “Source File Exclusions” give your file as src/apps/conf.php

Related

integrating sonarqube with jenkins insufficient privileges error

I followed this video https://www.youtube.com/watch?v=jh7utASgKj4 to integrate sonarqube with jenkins. However, I get the insufficient privileges error when scanning the code by sonarqube server. The version of sonarqube server is 6.7. how can I solve this problem?
Here is the analysis properties in the jenkins project
# Required metadata
sonar.projectKey = test-sonar
# Path to source directory
sonar.sources = /var/jenkins_home/workspace/$JOB_NAME/test-sonar/src
# bind sonar.java.binaries property
sonar.java.binaries=/var/jenkins_home/workspace/$JOB_NAME/test-sonar/target/classes
Here is the output of console.
INFO: SCM provider for this project is: git
INFO: 16 files to be analyzed
INFO: 16/16 files analyzed
INFO: 5 files had no CPD blocks
INFO: Calculating CPD for 8 files
INFO: CPD calculation finished
INFO: Analysis report generated in 132ms, dir size=124 KB
INFO: Analysis reports compressed in 48ms, zip size=61 KB
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 48.028s
INFO: Final Memory: 15M/304M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Insufficient privileges
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?
ERROR: SonarQube scanner exited with non-zero code: 1
If you are running the Sonar Analysis via Execute shell plugin for Jenkins, you need to supply the Username Password of a User which has the Execute Analysis rights on the SonarQube server you are trying to access.
To supply the username in the shell, you can use
-Dsonar.login=yourLoginName -Dsonar.password=*****
To set the Execute Analysis permission you can ask your DevOps team to give you access or if you are looking into that,
Goto Administration > Security > User/Groups.
Please make sure that you configure the Sonarqube UserID and Password having privileges to access sonar server (execute analysis permissions) in the Sonar plugin for Jenkins. This error might appear for 5.3 and higher versions when the anonymous access to sonar is disabled.

"Resource not found" trying to add junit tests into sonarqube

I am trying to associate junit test results with SonarQube.
Here is what I have for Sonar Properties:
sonar.projectKey=FXX
sonar.projectName=FUTURE_Jason
sonar.projectVersion=12.9.0
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.tests=test-build/junit/classes/
sonar.junit.reportsPath=test-build/junit/reports
When executing a Jenkins job associated with SonarQube, I am receiving the following warnings:
13:52:12.923 INFO - Sensor SurefireSensor
13:52:12.924 INFO - parsing /var/lib/jenkins/jobs/FUTURE_SONAR_Jason/workspace/test-build/junit/reports
13:52:13.472 WARN - Resource not found: msc.rc.model.AbstractTrackingUpdateTest
In the Jenkins workspace I have the directory test-build and it includes both the reports and classes.
$ ll /var/lib/jenkins/jobs/FUTURE_SONAR_Jason/workspace/test-build/junit/classes/msc/rc/model/AbstractTrackingUpdateTest.class
-rwxr-xr-x 1 build build 9590 Dec 14 14:39 /var/lib/jenkins/jobs/FUTURE_SONAR_Jason/workspace/test-build/junit/classes/msc/rc/model/AbstractTrackingUpdateTest.class
Any idea what I am missing?
I changed the sonar.tests property to point to the .java files, problem is now resolved.

Sonar runner Execution failure on Jenkins

I am trying to configure a Sonar Plugin on Jenkins, Executing this SonarJob on jenkins results in an error. The output console does not indicate whats causing this error. Looking for a way to debug this issue.
-Some info on the Setup
->The SonarJob workspace is copied from another Job
-> configured Sonar and Sonar Runner in Jenkins-> Configure System
-> Sonar Build Step is Triggered by "invoke Standalone Sonar Analysis" . The output console log is as follows
Thanks In Advance !
Lokesh
Started by user cheetahb#ca.ibm.com
[EnvInject] - Loading node environment variables.
Building on master in workspace /drv-cheetbld3_1/pipeline/jenkins/jobs/SonarQube1/workspace
Copied 2,820 artifacts from "BI-Pattern_3.0_build" build number 41
[workspace] $ /home/cheetahb/sonarhome/bin/sonar-runner Sonar_5.0_new -Dsonar.jdbc.driver=com.mysql.jdbc.Driver -Dsonar.jdbc.url=jdbc:mysql://9.37.213.8:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance ******** ******** -Dsonar.host.url=http:// vottlokesh. ottawa.ibm.com:9000/ -Dsonar.projectBaseDir=/drv-cheetbld3_1/pipeline/jenkins/jobs/SonarQube1/workspace -Dsonar.projectName=biPattern3.0 -Dsonar.projectVersion=1.0 -Dsonar.projectKey=biproject -Dsonar.verbose=true -Dsonar.sources=/drv-cheetbld3_1/pipeline/jenkins/jobs/SonarQube1/workspace
SonarQube Runner 2.4
Java 1.7.0_65 Oracle Corporation (64-bit)
Linux 2.6.32-431.20.5.el6.x86_64 amd64
INFO: Runner configuration file: /home/cheetahb/sonarhome/conf/sonar-runner.properties
INFO: Project configuration file: NONE
INFO: SonarQube Server 5.0
18:23:43.161 INFO - Load global referentials...
18:23:43.181 DEBUG - Download: http:// vottlokesh.ottawa.ibm.com:9000/batch/global (no proxy)
18:23:43.926 INFO - Load global referentials done: 768 ms
18:23:43.932 INFO - User cache: /home/cheetahb/.sonar/cache
18:23:43.947 INFO - Install plugins
18:23:43.947 DEBUG - Download index of plugins
18:23:43.947 DEBUG - Download: http:// vottlokesh.ottawa.ibm.com:9000/deploy/plugins/index.txt (no proxy)
18:23:44.066 INFO - Install JDBC driver
18:23:44.066 DEBUG - Download index of jdbc-driver
18:23:44.067 DEBUG - Download: http:// vottlokesh.ottawa.ibm.com:9000/deploy/jdbc-driver.txt (no proxy)
18:23:44.079 INFO - Create JDBC datasource for jdbc:mysql://9.37.213.8:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
18:23:45.834 DEBUG - Testing JDBC connection
18:23:48.209 DEBUG - Download: http:// vottlokesh.ottawa.ibm.com:9000/api/server (no proxy)
18:23:48.523 INFO - Initializing Hibernate
18:23:48.526 DEBUG - hibernate.generate_statistics: false
18:23:48.527 DEBUG - hibernate.dialect: org.sonar.core.persistence.dialect.MySql$MySqlWithDecimalDialect
18:23:48.527 DEBUG - hibernate.connection.provider_class: org.sonar.jpa.session.CustomHibernateConnectionProvider
18:23:50.751 DEBUG - Loaded 2689 properties from l10n bundles
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 8.801s
Final Memory: 35M/355M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: Task Sonar_5.0_new does not exist
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
Finished: FAILURE
You must get rid of the Sonar_5.0_new label that you set on the Task to run field in your Jenkins job configuration.

Sonar Runner does not use properties of sonar-project.properties

I am using SonarQube Runner 2.4 at jenkins since today but the analysis fail with the message:
SonarQube Runner 2.4
Java 1.7.0_51 Oracle Corporation (64-bit)
INFO: Runner configuration file: /.jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner_2.4/conf/sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "en_US", source code encoding: "ISO-8859-1" (analysis is platform dependent)
INFO: Work directory: /.jenkins/workspace/Sonar/.sonar
INFO: SonarQube Server 4.3.2
23:21:42.176 INFO - Load batch settings
23:21:42.160 INFO - User cache: /.sonar/cache
23:21:42.270 INFO - Install plugins
23:21:43.322 INFO - Install JDBC driver
23:21:43.329 INFO - Create JDBC datasource for jdbc:mysql://xxx
23:21:45.505 INFO - Initializing Hibernate
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 5.214s
Final Memory: 21M/429M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must define the following mandatory properties for ‚com.mypackage:MyProject: sonar.sources
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
[BFA] Scanning build for known causes...
[BFA] Done. 0s
Notifying upstream projects of job completion
Finished: FAILURE
If I add the property "MyProject.sonar.sources=src" In the project properties in Jenkins (I use "Invoke Standalone Sonar Analysis"). I will receive the error message
ERROR: Caused by: Findbugs needs sources to be compiled. Please build project before executing sonar and check the location of compiled classes.
This means the sonar-project.properties (/.jenkins/workspace/Deploy/MyProject/sonar-project.properties) is not read or used because there are all values defined:
sonar.language=java
sonar.projectName=MyProject
sonar.projectVersion=0.1
sonar.binaries=bin
sonar.projectDescription=
sonar.projectKey=MyProjectKey
sonar.sources=src
When sonar is executed I can see the correct path to MyProject where :
-DMyProject.sonar.projectBaseDir=/.jenkins/workspace/Deploy/MyProject
Or does the name of sonar-project.properties changed?
Please build the project in the release mode. After the build happens you will get the dll's produced somewhere. you have to point to that location.

SonarQube Runner 2.4 can not find sonar.sources in sonar-project.properties even it exist

I am using SonarQube Runner 2.4 at jenkins since today but the analysis fail with the message:
SonarQube Runner 2.4
Java 1.7.0_51 Oracle Corporation (64-bit)
INFO: Runner configuration file: /.jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner_2.4/conf/sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "en_US", source code encoding: "ISO-8859-1" (analysis is platform dependent)
INFO: Work directory: /.jenkins/workspace/Sonar/.sonar
INFO: SonarQube Server 4.3.2
23:21:42.176 INFO - Load batch settings
23:21:42.160 INFO - User cache: /.sonar/cache
23:21:42.270 INFO - Install plugins
23:21:43.322 INFO - Install JDBC driver
23:21:43.329 INFO - Create JDBC datasource for jdbc:mysql://xxx
23:21:45.505 INFO - Initializing Hibernate
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 5.214s
Final Memory: 21M/429M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must define the following mandatory properties for ‚com.mypackage:MyProject: sonar.sources
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
[BFA] Scanning build for known causes...
[BFA] Done. 0s
Notifying upstream projects of job completion
Finished: FAILURE
But sonar-project.properties of My_Project contain sonar.sources.
sonar.language=java
sonar.projectName=My_Project
sonar.projectVersion=0.1
sonar.binaries=bin
sonar.projectDescription=
sonar.projectKey=MyProjectKey
sonar.sources=src
Where is the problem?
Greetings
Try adding "sonar.sources=." See if this works or not. Please add the log if the problem still persists.
sonar.sources and sonar.binaries path should be relative to the sonar runner home. You need to check that of the path is right as just src.

Resources