Link to SonarQube on Jenkins job not available - jenkins

on the main page of a Jenkins job, I see the SonarQube icon, which should be a link, but it's just text:
I use...
Jenkins 1.596.2 (also tried 1.609.1)
Jenkins SonarQube-Plugin 2.1 (also tried 2.2.1)
Maven 3.3.1
sonar-maven-plugin:2.6 (when configuring SonarQube post build action)
sonar runner 2.4 (when configuring SonarQube analysis build step)
After browsing the source code of the jenkins sonarqube-plugin, I found that SonarUtils.extractSonarProjectURLFromLogs() seems to be broken. It parses the console output for the regexp "ANALYSIS SUCCESSFUL, you can browse (.*)".
My console output never prints this line. It just prints "ANALYSIS SUCCESSFUL".
Is this a known issue?

From what I can see in your logs, you are running the analysis in "preview" mode:
... -Dsonar.analysis.mode=preview ...
As you can read on the documentation about preview mode:
The source code is analyzed but the measures and issues are not pushed
to the SonarQube database. Therefore, they cannot be browsed through
the web interface.
So this is normal that you only get a ANALYSIS SUCCESSFUL message without the related SQ URL (because results are not pushed to the server in preview mode).

Related

Sonar-Gerrit integration shows error in Jenkins

There is a Jenkins freestyle job that is triggered by some Gerrit events.In response to triggers, it downloads the changes and runs a Sonarqube Analysis. The Sonarqube comments detailing the results are to be posted on Gerrit after the analysis is complete.This is the expected behaviour.
As of now, In Jenkins, the Sonarqube execution is success. But the build is failed mentioning the error " *ERROR: Build step failed with exception java.lang.IllegalArgumentException: Gerrit change number is empty*
Could anyone please help on this?
Reference:https://plugins.jenkins.io/sonar-gerrit/
Followed the same steps as mentioned in the above document.
Jenkins console output
Expected: The Sonarqube should post the comments to the respective Gerrit change,whether the Sonar-verified is +1/-1.

Jenkins Performance plugin not listing URLs from JMeter test

In my JMeter setup, I have the following config in my Test Aggregate Report (named loadTestAggregate) in order to list all the erroring URLs in my load test :
When I run my JMeter test locally, this Test Aggregate Report correctly displays the results (as a .csv) and the URLs are displayed as required (i.e. the response code, response message and URL are all displayed).
I then set up this test to run via Jenkins (with the Performance plugin installed).
Below is the Jenkinsfile used to run this test via Jenkins;
sh "jmeter -Jjmeter.save.saveservice.url=true -n -t loadTest.jmx -JTest_Url=${env.TEST_URL} -l jmeter_results.jtl"
perfReport errorFailedThreshold: 5.00, sourceDataFiles:'loadTestAggregate.csv'
However, when the test is completed and I look in Jenkins via the Performance plugin, the URLs are not displayed.
All that's displayed is the following;
Is it possible to get these (erroring) URLs to be listed via the Jenkins Performance plugin?
If so, am I missing something here as my config for the Test Aggregate report works locally but not via Jenkins, so I can only presume that it's a Performance plugin issue.
Many thanks
They're "aggregate" charts per Sampler label
As a workaround you can change the Sampler label (HTTP Request) to the Sampler URL, it can be done via JSR223 PostProcessor and the following Groovy code:
prev.setSampleLabel(prev.getUrlAsString())
where prev stands for the previous SampleResult, see Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information.
Demo:

sonarqube project failed

I am using sonarqube 6.1 which is integrated with Jenkins 2.48. In Jenkins, it is showing my build ran successfully. But in Sonarqube, it is showing Failed.
Jenkins :
POST BUILD TASK : SUCCESS
END OF POST BUILD TASK : 0
Finished: SUCCESS
Sonarqube (Failed in red color) :
[![enter image description here][1]][1]
What "failed" mean in Sonarqube project?
Does it means wrong configuration or wrong iteration with Jenkins?
How can I solve this?
I have checked in background task. Project failed recently but in project summery, it is showing past failed details.
[![enter image description here][2]][2]
The SonarQube analysis is split into two separate tasks:
The 'Sonar Scanner' runs the analysis on the code (which is what happens in your Jenkins build) and packs the results and sends them of to the SonarQube instance.
The 'Compute Engine' (CE) uses the packed results and calculates several quality metrics (for ex. the CE is responsible to update the Quality Gate status)
As your Jenkins build is successful this means that the Scanner did do it's work just fine, but on the CE side it failed to process the results of the scanner.
See Background Tasks documentation on how to obtain the log of the CE task and see why the analysis results processing failed.
The default configuration for SonarQube way flags the code as failed if:
the coverage on new code is less than 80%
percentage of duplicated lines on new code is greater than 3
maintainability, reliability or security rating is worse than A

Show SonarQube result link on Jenkins Job page

I use jenkins and sonar to analyze some projects. The sonar analyzing triggered over the groovy pipeline script with the following code:
stage('SonarQube analysis')
def scannerHome = tool 'SonarQube_Scanner_Prod';
sh "${scannerHome}/bin/sonar-scanner -e -Dsonar.host.url=... -Dsonar.projectKey=... -Dsonar.projectName=... -Dsonar.sources=... -Dsonar.projectVersion=..."
This work fine. Now I want a link on the jenkins job page. To come to the sonar results on the server. After the sonar analysis run, the link is on the console. Can i add this link to the status page? Or add a link to the left menu? Thank you for help.
As far I know Once the job is complete, the plugin will detect that a SonarQube analysis was made during the build and display a badge and a widget on the job page with a link to the SonarQube dashboard as well as quality gate status.
Please refer this and verify your configurations.

Jenkins + Sonar create project

I'm having problem with the execution of sonar analysis from Jenkins jobs. I have Jenkins ver. 1.621 and sonar Version 5.1.
I had this tools working and executing sonar analysis from Jenkins til I define user authentication with LDAP in both applications. There is no error in the execution of jobs and I can see the execution of sonar command task in Jenkins project log but when I check sonar the analysis never happened. I just check "everything" but I don't know what could be, I thinking could be role/permissions but I checked this and it seem right.
Any idea about What could be happened?
These are my specification:
Jenkins
Project-Sonar. This is the content of "Analysis properties" defined in the Post Steps->Invoke StandAlone SonarQube Analysis.
# Required metadata
sonar.projectKey=plandecuentas
sonar.projectName=plandecuentas
sonar.projectVersion=1.0
# Set modules IDs
#sonar.modules=src
# Comma-separated paths to directories with sources (required)
sonar.sources=src
# Language
sonar.language=java
# Encoding of the source files
sonar.sourceEncoding=UTF-8
Jenkins-Sonar Library:
Sonar-Qube Plugin 2.2.1
I have configured this libraries with the same info before enable LDAP authentication.

Resources