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.
Related
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.
Can you please any one tell me how can publish the Jacoco Report in Jenkins.
I mean after the pipeline execution done the test report need to show on the jenkins dhash Borad.
You should use jacoco step available with Jacoco plugin
jacoco classPattern: "**/classes", sourcePattern: "**/src/main/java"
https://jenkins.io/doc/pipeline/steps/jacoco/#-jacoco-record-jacoco-coverage-report
You can play around with this on the Snippet Generator available at https://<yourJenkins>/pipeline-syntax/
How can I get the job list in jenkins after I execute the jobdsl ?
Jenkin JobDSL is nice to manage the jenkins jobs. When you execute the jobDSL, jenkins can help to generate the jobs are expected. Even more, if the job is created, you can choose to skip or overwrite.
Now I want to trigger the build directly after it is new generated.
See sample console output from jenkins build.
Processing DSL script demoJob.groovy
Added items:
GeneratedJob{name='simpliest-job-ever'}
Existing items:
GeneratedJob{name=’existing-job'}
How can I get the jobname simpliest-job-ever in jenkins? And in this case, I don't want to build existing-job
Scan the console log could be choice, but it is not elegant enough.
You can trigger a build from the DSL script using the queue method (docs).
job('simpliest-job-ever') {
// ...
}
queue('simpliest-job-ever')
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).
I am using one Jenkins setup/instance to run the smoke tests (i.e using this Jenkins for QA only). Now I have to use another Jenkins job url in my first instance. The purpose is after successful code staging (on Dev Jenkins) it should automatically trigger the smoke tests (on QA Jenkins).
I know that Job import plugin can be used to achieve this but I am not sure as in where exactly to configure it. Googled it as well but unable to find anything.
Any help on this would be really appreciated.
Thanks in advance !
Just import the Job Import plugin, restart Jenkins and then access the plugin on your browser using the URL:
< Jenkins URL >/job-import
For Ex: http://localhost:8080/jenkins/job-import
If you get an error page here, cross-check whether plugin installation was successful or not. This won't work until all the dependent plugins are get installed successfully.
If you have a HTTP access to the DEV machine, maybe you can use the URL trigger plugin:
https://wiki.jenkins-ci.org/display/JENKINS/URLTrigger+Plugin
And trigger the last successful build number URL:
http://YOUR_JENKINS_SERVER/job/YOUR_JOB/lastSuccessfulBuild/buildNumber
If you don't have any access between your QA and DEV machines, it will be hard to trigger a job ;)
Download Jenkins JAR file
Go to location where JAR is located and enter following command
java -jar jenkins-cli.jar -s http://localhost:8080/jenkins/ -auth admin:password create-job UploadToReleases < C:\Users\admin\UploadtoReleases.xml
create-job is command to import a job.
create-job always required name of jenkins job followed by < filename