jenkins plugin for the sonarqube scanner is not working - jenkins-pipeline

I have install the plugin for the sonarqube in which i got scanner also so i configure the scanner and the server both for my project. In First stage of my pipeline I my trying to clone git repo and in the second stage i set the configuration for the sonar-scanner analysis but the sonar-scanner plugin is not able to scann project
an it will through the error like the below:-
C:\ProgramData\Jenkins.jenkins\workspace\demo7-pipeline>sonarscanner
-D sonar.login=admin -D sonar.password=Khushal#123 -D sonar.projectKey=example -D
sonar.exclusions=vendor/,resources/,**/*.java -D
sonar.host.url=http://localhost:9000 'sonarscanner' is not recognized
as an internal or external command, operable program or batch file.
'sonarscanner' here is the plugin in the jenkines in which i have set the scanner name as sonarscannr.But it could not scann my project which i have clone
I am trying with local path of my sonar-scanner it works but i want to scann my project with the help of jenkins plugin only i dont want to scann my project to local set sonarscanner.Please show some help thank you

Related

Jenkins Karate pipeline project could not execute maven goal

Error message from the Jenkins console:
The goal you specified requires a project to execute but there is no
POM in this directory
(/home/jenkins/workspace/Dealer-API-v2-test-automation_qa). Please
verify you invoked Maven from the correct directory.
Maven command in the Jenkins file:
sh script : "mvn test '-Dkarate.options=--tags #regression' -Dtest=TestParallel -DargLine='-Dkarate.env=qa'"
How can I execute this maven command in my pipeline script?
Just a guess but if you add -f Dealer-API-v2-test-automation_qa/pom.xml or something like that, it may start working. Or do a cd Dealer-API-v2-test-automation_qa, before doing mvn test, hope that helps.

SonarQube analysis works in IDE but not in Jenkins Pipeline

Which versions am I using (SonarQube, Scanner, Plugin, and any relevant extension):
SonarQube 7.9.1 (on a remote server)
Sonar maven plugin 3.7.0.1746 (in my pom.xml file)
Jenkins 2.222.1 (local server)
Maven 3.6.0
What am I trying to achieve:
I want to perform an analysis with a Jenkins Pipeline with my remote server
What have I tried so far to achieve this :
I have succeed to do an analysis with my IDE (intelliJ) and it works with the command :
mvn -B sonar:sonar
After that, the server note the last analysis with the Quality Gate.
Nevertheless, it does not work with my Jenkins Pipeline.
I do not understand why it works with the IDE and not with Jenkins.
I have put in my pom.xml a sonar.login which is a specific user token. This user has the right to execute an analysis on this particular project. In my ~/.m2/settings.xml, I have put the sonar.host.url.
I also tried to set up manually a SonarQube server in Jenkins (in system configuration). I put there the url and my token thanks to a secret text but it does not work to.
I have also generated a Webhook but this is for the qualitygate variable in the pipeline and I don’t think it matters here.
I don’t know what to test now…
Any idea ?
Thanks
It is ok now : I have added on a sonar installer in the settings. In addition I move the sonar.host.url from ~/.m2/settings.xml to my pom.xml file.

SonarQube analysis from maven and Jenkins have different results

I am using SonarQube version 6.7 for running analysis of Maven projects using the command mvn clean verify sonar:sonar from the project directory using command prompt and get the results. The sonar configurations in settings.xml for maven (v3.5.3) are added respectively.
In Jenkins (version 2.161), I have installed SonarQube Scanner for Jenkins (v2.8.1) plugin. The SonarQube Server configuration is configured as below.
In the Jenkins maven project, I have configured the post steps as below.
I have checked the Prepare SonarQube Scanner environment in the Build Environment section and the Build goal is -e clean verify sonar:sonar.
My issue is, when the SonarQube analysis for a maven project is triggered through command prompt using the command mvn clean verify sonar:sonar, I am getting the results as expected. But when the Jenkins job is triggered with the configurations above for the same maven project, the results are different and incorrect. What am I missing?
P.S- In the Post-build Actions, I can see the SonarQube analysis with maven is deprecated.
Thanks in advance.
You use different scanners. First you used SonarScanner for Maven (mvn sonar:sonar). Next you used Basi SonarScanner, which requires manual configuration of all options.
The best option to sole it is always use the same scanner. You have Maven project, so you can enable Prepare SonarQube Scanner environment in Build Environment, and next execute Sonar goal $SONAR_MAVEN_GOAL in Build.

Jenkins Maven Build Step fails but runs from command line

I've been searching the web and StackOverflow for a solution. Problem is that Jenkins will not invoke mvn from the the build step. In my build step, I'm using Invoke top-level Maven targets. From the command line mvn clean install runs just fine from the directory where the POM file is located. So I believe Maven is installed correctly.
From the console I see:
[XXXX] $ cmd.exe /C "mvn -f C:\Users\XXX\XXX\XXX\pom.xml clean install && exit %%ERRORLEVEL%%"
Error message is:
'mvn' is not recognized as an internal or external command, operable program or batch file.
What I have tried:
change the settings file option to point too the settings.xml in the Maven install folder
change the global setting file option to point too the settings.xml in the Maven install folder
I've set the MAVEN_HOME environment variable in Jenkins Configure System
What I expect to happen:
Maven to build my project from the build step.
I just removed pom.xml file from the path.. it's worked ..
So try the below option

Build Jenkins Sonar-ruby-plugin

I am trying to build sonar-ruby-plugin for jenkins i.e, to create a .hpi file every time I run the command:
mvn package
it creates a target folder but there is no .hpi file.
https://github.com/GoDaddy-Hosting/ruby-sonar-plugin
This is a plugin for SonarQube server, not Jenkins.
You should:
build the plugin by mvn package
copy to SONARQUBE_HOME/extensions/plugins directory
restart SonarQube
run analysis (you can execute SonarQube in Jenkins; read more on SonarQube wiki)

Resources