The SonarQube Post-build Action is deprecated - jenkins

Using Jenkins 1.642.2 for code analysis with SonarQube 5.6.1 for all my maven projects.
When I use maven goal sonar:sonar they take more time to analyse files (more than 7 seconds by file) :
[INFO] Sensor SCM Sensor
[INFO] SCM provider for this project is: svn
[INFO] 1079 files to be analyzed
[INFO]
[INFO] 2/1079 files analyzed
[INFO] 3/1079 files analyzed
[INFO] 4/1079 files analyzed
[INFO] 5/1079 files analyzed
When I use the SonarQube Scanner with this config :
then i have this error :
WARN: Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
INFO: User cache: /var/lib/jenkins/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=43ms
INFO: SonarQube server 5.6.1
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Process project properties
INFO: ---------------------------------------------------------------------- --
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.621s
INFO: Final Memory: 39M/132M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
Build step 'Execute SonarQube Scanner' marked build as failure
Finished: FAILURE
My settings file :
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>
jdbc:mysql://11.230.5.88:3306/sonar
</sonar.jdbc.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://sonarqube-groupe.com/
</sonar.host.url>
</properties>
</profile>
Any idea to solve this problem because i have a problem to understand the new sonarqube use
i must make a sonar-project.properties file for the maven project?

You can and should still analyze with Maven, using a Build Step. As stated in the docs, you should first "Enable injection of SonarQube server configuration" at the global configuration level, and then in your build enable the Build Environment Option "Prepare SonarQube Scanner environment". Then you can set your Maven goal to the following:
$SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN

Related

Please check that inclusion/exclusion patterns produce disjoint sets for main and test files

Jenkin 2.289
Java 11
sonarqube-7.9.1
Here my Jenkins's job that use plugin "SonarQube scanner":
# Language
sonar.language=java
#BaseDir
sonar.projectBaseDir=/home/myUser/.jenkins/workspace/my-project-sonar/my-project
# Set modules IDs
sonar.modules=my-project-common,my-project-dalReader,my-project-mediation,my-project-reports,my-project-server,my-project-dal,my-project-dalWriter,my-project-sdn
# Modules inherit properties set at parent level
sonar.sources=./
#sonar.sources=**/src/main/**
#**/src/**
sonar.exclusions=**/generated-sources/**,**/src/test/**,**/*Header.java,./.svn,./my-project-it,./my-project-parent,./my-project-client
# By default, the base directory for a module is <current_dir>/<module_ID>.
common-model.sonar.projectBaseDir=common-model
my-project-common.sonar.projectBaseDir=my-project-common
my-project-sdn.sonar.projectBaseDir=my-project-sdn
sonar.junit.reportsPath=**/target/surefire-reports/*
# Comma-separated paths to directories containing the compiled bytecode files corresponding to your source files
sonar.java.binaries=**/target/classes/**
# Tells SonarQube where the unit tests code coverage report is
sonar.jacoco.reportPath=**/target/jacoco-ut.exec
# Encoding of the source files
sonar.sourceEncoding=UTF-8
But job get error:
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 15.111s
INFO: Final Memory: 13M/550M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: File myproject-server/server-deployment/pom.xml can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
ERROR: SonarQube scanner exited with non-zero code: 2
Finished: FAILURE
You appear to be using the Maven SonarQube plugin's "sonar" goal, so you should not specify a "sonar.sources" value. That is done by the plugin. Maven uses the knowledge of the pom to provide parameters to the SonarQube scanner. Similarly for "sonar.java.binaries".
Once you get past this problem, you may discover you're not getting any test coverage acknowledged. I believe your use of the "sonar.jacoco.reportPath" property is obsolete. You can verify that first.

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.

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.

Not created by default settings.xml in $/user/.m2/repository path using Maven

I tried below command its work properly
C:\Documents and Settings\users>mvn -v
Apache Maven 3.0 (r1004208; 2010-10-04 17:20:56+0530)
Java version: 1.6.0_21
Java home: C:\Program Files\Java\jdk1.6.0_21\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
and once I tried to compile simple HelloWorld.java program. Its give me below error...
C:\my-app>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Quick Start Archetype 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: repo1.maven.org/maven2/org/apache/maven/plugins/maven-resour
ces-plugin/2.4.3/maven-resources-plugin-2.4.3.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.454s
[INFO] Finished at: Thu Nov 18 13:08:50 IST 2010
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of i
ts dependencies could not be resolved: Could not transfer artifact org.apache.ma
ven.plugins:maven-resources-plugin:jar:2.4.3 from central (http://repo1.maven.or
g/maven2): Error transferring file: Connection refused: connect -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResoluti
onException
Please any one update me with proper solutions.
First, you really should format your questions better. Just cutting and pasting without any regard what it would look like when submitted doesn't help you in getting a quick and concise answer.
Second, what exactly is your question? You subject says one thing, but your text says another.
Now I'll take a stab at both your subject and your text.
As far as the subject is concerned, the settings.xml file is not automatically created by Maven. You have to create this and configure it the way you want. See this website for more info about the settings.xml.
As far as the text is concerned, looks like you do not have access to the Maven repo. This can because by a number things. The most obvious ones are:
The repository is not specified in the project's pom.xml file as described here.
The server you are running this on does not have access to http://repo1.maven.org/maven2/ due to firewall or internet connectivity reasons.
Double check that:
this was not an intermittent problem
you didn't get bad metadata (and clean up the entire ~/.m2/repository/org/apache/maven/plugins/maven-resources-plugin/)

Resources