Sonarqube invalid value for java binaries - maven

I'm trying to upload my project to a remote sonarqube server.
This is the command I run sonar scanner:
sonar-scanner -Dsonar.projectKey=my-project -Dsonar.host.url=https://xxxx:9000 -Dsonar.login=the-secret-key -Dsonar.java.binaries=**/target/classes
but it throws the error on java.binaries.
INFO: Configured Java source version (sonar.java.source):
none
INFO: JavaClasspath initialization
ERROR: Invalid value for sonar.java.binaries
INFO: ------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------
INFO: Total time: 20.276s
INFO: Final Memory: 10M/161M
INFO: ------------------------------------------------------
------------------
ERROR: Error during SonarQube Scanner execution
No files nor directories matching **/target/classes
I tried different values like ./target, /target/, /target/classes (where the jar is being stored). However, I am encountering this error of not found. (even though the directory exists)
By running sonar:sonar on my IDE and maven sonar:sonar on my terminal would send over the result to sonarqube, but my goal is to include this command in my jet-steps

Very old post but may help someone. I had similar issue and below configuration worked for me:
sonar.sources=src/main/java
sonar.java.binaries=target/classes

We also experienced a similar issue on our project (Maven multimodule), and for us the following configuration made things work:
sonar.java.binaries=.
sonar.java.source=8
sonar.sources=.
PS Java source is just for reference, it should not matter to fix the issue.

In my case, Im working with gradle, and we have subaplications, we are using sonarqube plugin from azure. I have to adapt to find binaries like this way:
sonar.java.binaries=./streamHubAndroidSDK/build/**,./nota/build/**,./app/build/**
But later I found that its better to define like this:
sonar.java.binaries=**/build/**
I can find this first building Android-Gradle project locally, and looking for all .class generated with bash:
find . -path '*/build/*.class' | xargs | tr ' ' ','

Related

How to set up apache ranger on apple macbook pro m1

I'm trying to set up apache ranger for work using this https://github.com/apache/ranger/tree/master/dev-support/ranger-docker
however by running
mvn clean package -DskipTests
I'm getting the following error: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.6:exploded (prepare) on project security-admin-web: Execution prepare of goal org.apache.maven.plugins:maven-war-plugin:2.6:exploded failed: Unable to load the mojo 'exploded' in the plugin 'org.apache.maven.plugins:maven-war-plugin:2.6' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: null The entire error can be seen in this picture:
[1]
and as an alternative provided in the github, when I run:
docker-compose -f docker-compose.ranger-base.yml -f docker-compose.ranger-build.yml up
I get the error:
ranger-build | The JAVA_HOME environment variable is not defined correctly
ranger-build | This environment variable is needed to run this program
ranger-build | NB: JAVA_HOME should point to a JDK not a JRE
ranger-build | mv: cannot stat 'target/ranger-*': No such file or directory
ranger-build exited with code 1
I have also tried following https://medium.com/swlh/hands-on-apache-ranger-docker-poc-with-hadoop-hdfs-hive-presto-814344a03a17
however it gets stuck in the ranger-admin container and localhost:6080 doesn't work.
[1]: https://i.stack.imgur.com/57ubI.jpg
I was able to solve this by downgrading my maven to 3.6.3 as I was having incompatibility issues, although this particular issue was resolved by adding maven war 2.6 plug in in pom.xml but then more incompatibility issues arose so i had to uninstall and reinstall a completely different maven version and that fixed all the issues.

Sonar Qube code analysis failed with exist code 1

I am using sonar qube for code analyzer but getting error as below:
Preparing `SonarQube` scanner...
`realpath`: '': No such file or directory
ERROR in /opt/resource/out : line 85 with exit code 1
and not getting specific reason why it is failing.
You are missing some input in your configuration, most likely something with maven (default settings.xml pointing to wrong repo). Default maven install folder for concourse-sonarqube-resource is /opt/apache-maven. By using the debug flag, whole trace (mvn -X) will be shown and you get your specific reason.
type: sonar-runner
source:
host_url: ((sonarqube.url))
__debug: true

Running SonarQube scanner sonar-web-frontend IlligalStateException

I am running the SonarScanner using the sonar-web-frontend-plugin from the commandLine, it picks up the files and runs and I get an execution Failure
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Report processing did not complete successfully
: FAILED
My sonar-project.properties look like this
# must be unique in a given SonarQube instance
sonar.projectKey=Test.UI
# this is the name displayed in the SonarQube UI
sonar.projectName=Test.UI
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
sonar.sources=src/app
# exclude some files and folders (typically dependencies)
sonar.exclusions=bower_components/**/*, node_modules/**/*
# Encoding of the source files
sonar.sourceEncoding=UTF-8
You have the Build Breaker plugin installed on your SonarQube instance.
Your project failed its quality gate.
The Build Breaker plugin did its job, and "broke" (returned a non-success status code) your build.
Seems like it was because i had the default JS rules still installed and they can't exist side by side.

SonarQube can't find the project configuration path

Anyone knows how to figure this out?
C:\sonar-runner\bin\..
SonarQube Runner 2.3
Java 1.7.0_45 Oracle Corporation (64-bit)
Windows Server 2012 6.2 amd64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: C:\sonar-runner\bin\..\conf\sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "pt_BR", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Work directory: C:\sonar-runner\bin\.sonar
INFO: SonarQube Server 4.0
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 7.425s
Final Memory: 6M/31M
INFO: -----
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must define the following mandatory properties for 'Unknow
n': sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
For some reason the SonarQube can't find the configuration project path
its return NONE from the INFO.
I already have the file in the conf path of the sonar-runner.
If you read carefully the doc page "Analyzing with SonarQube Runner", you can read:
Run the following command from the project base directory to launch the analysis:
The most important part is "from the project base directory". This should answer your question.
Important: the name of the project configuration file must be:
"sonar-project.properties" (not sonar-scanner.properties)
And you have to launch the sonar-scaner command from the path of your project.
You need to add Project config file in the base directory.
That is C:\sonar-runner\bin

Sonar-runner fails due to missing cxx-language plugin, although installed

I am very new to Sonar and in the process of setting up my first server/project.
Environment:
OS: Windows Server 2008 R2 / amd64 / 6.1
App Server: Tomcat/7.0.40I, deployed the Sonar WAR file (3.5.1).
DB: MySQL 5.6.11
(relevant) Plugins:
Sonar C++ Community Plugin (0.2)
The plugin is visible under General Settings --> Sonar C++ Community Plugin
sonar-project.properties
# Required metadata
sonar.projectKey=test:pmc
sonar.projectName=PMC
sonar.projectVersion=1.0
sonar.language=c++
# Comma-separated paths to directories with sources (required)
sonar.sources=c:/SVN/Development/test/PMC/trunk/AppServer,c:/SVN/Development/test/PMC/trunk/PmcShared,c:/SVN/Development/test/PMC/trunk/WebServer,c:/SVN/Development/test/PMC/trunk/Tools
# Optional path to the CppCheck program required to activate some CppCheck rules
sonar.cpp.cppcheck.path=C:/Program Files (x86)/Cppcheck/cppcheck.exe
# Encoding of the source files
sonar.sourceEncoding=UTF-8
The thing I do not understand is that it cannot find a plugin that supports the 'cxx' language:
C:\Users\Administrator\Documents\sonar-projects\PMC>sonar-runner
C:\Users\Administrator\Documents\sonar-runner-2.2.1
Sonar Runner 2.2.1
Java 1.7.0_21 Oracle Corporation (64-bit)
Windows Server 2008 R2 6.1 amd64
INFO: Runner configuration file: C:\Users\Administrator\Documents\sonar-runner-2.2.1\conf\sonar-runner.properties
INFO: Project configuration file: C:\Users\Administrator\Documents\sonar-projects\PMC\sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: C:\Users\Administrator\Documents\sonar-projects\PMC\.sonar
INFO: Sonar Server 3.5.1
15:20:54.231 INFO - Load batch settings
15:20:54.794 INFO - User cache: C:\Users\Administrator\.sonar\cache
15:20:54.797 INFO - Install plugins
15:20:55.742 INFO - ------------- Executing Project Scan
15:20:56.482 INFO - Install JDBC driver
15:20:56.487 INFO - Apply project exclusions
15:20:56.493 INFO - Create JDBC datasource for jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
15:20:56.771 INFO - Initializing Hibernate
15:20:59.229 INFO - ------------- Inspecting PMC
15:20:59.229 INFO - Load module settings
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 6.162s
Final Memory: 13M/221M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must install a plugin that supports the language 'cxx'
ERROR:
ERROR: To see the full stack trace of the errors, re-run Sonar Runner with the -e switch.
ERROR: Re-run Sonar Runner using the -X switch to enable full debug logging.
I do have the Sonar C++ Community Plugin installed so I guess I am missing the obvious...could someone please help me getting started?
It seems I made a mistake in the configuration file. I re-created it and now the job runs! This issue is closed and the configurations above will work.
I had a similar error with the C# plugin:
ERROR: Caused by: You must install a plugin that supports the language 'cs '
Please remark the 'cs '
After long time I spotted the extra ' ' after 'cs'. When removing the extra space in the configuration file it worked. It seems like sonar-runner don't use "trim".
For new users, if you still getting this error (SonarQube 4+) start the server, go to the 'Settings' ( top right ) then search for 'Update center' there you add missing modules , next restart Server. it should works
Source: Link from official project website
To find the string required to activate any given SonarQube language plugin, go to "Settings" -> "System" -> "Update Center". For each plugin, the short name will be in square brackets to the right of the human-readable name.
C / C++ / Objective-C [cpp]
In this example, "cpp" is the name to use in the sonar.language property in your sonar-project.properties.

Resources