Jenkins + Sonar create project - jenkins

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.

Related

JMeter & Jenkins - passing jmeter parameters to downstream build

The Setup - A jenkins job using jenkins parameters testApp and testEnv. The Execution Batch looks like this:
C:\jmeter\apache-jmeter-3.2\bin\jmeter.bat -n -t
C:\JMeter\Scripts\API_scripts\%testApp%.jmx -Jtestenv=%testEnv% -JtestApp=%testApp% -JtestBrowser=NA -l
C:\AUTO_Results\jtl\%testApp%_%testEnv%.jtl
Post-build Actions
Console output (build lob) parsing with a global rule so that the Failures that are logged in the Jenkins Console window will consider the JMeter script failing. (discussed Jenkins shows JMeter script failure even though the script actually passed)
Triggered parameterized build - this is a separate jmeter script that updates a wiki page with either PASS/FAIL and uploads the JMeter report.
The Issue - How do I get the downstream Triggered build to use the parameters from the upstream script? I set the Parameter = Current build parameters but it's not applying those. Also, I wont know the value of the testResult parameter until the upstream build finishes. I tried adding %testResult%=PASS to the 'Predefined parameters' box
As per Parameterized Trigger Plugin page:
The parameters section can contain a combination of one or more of the following:
a set of predefined properties
properties from a properties file read from the workspace of the triggering build
the parameters of the current build
Subversion revision: makes sure the triggered projects are built with the same revision(s) of the triggering build. You still have to make sure those projects are actually configured to checkout the right Subversion URLs.
Restrict matrix execution to a subset: allows you to specify the same combination filter expression as you use in the matrix project configuration and further restricts the subset of the downstream matrix builds to be run.
So you basically need to copy over the parameters you would like to have in the "downstream" job from the current one.
As a workaround to current performance plugin limitations you can consider running JMeter using Taurus tool as a wrapper, it has flexible and powerful pass/fail criteria subsystem which will basically return to Jenkins non-zero exit code triggering build failure in case of issue in the test. If everything goes well Taurus exit code will be 0 which is considered successful by Jenkins. Check out How to Run Taurus with the Jenkins Performance Plugin article for more details.

sonar.projectbasedir not working in Jenkins

I have configured SonarRunner 2.3 in the Jenkins. In Execute SonarQube Scanner build process, I have updated my properties as
# Required metadata
sonar.projectKey=test
sonar.projectName=test
sonar.projectVersion=1.0
sonar.projectBaseDir=/opt/app/jenkins/var/lib/jenkins/jobs/test1-BuildJob/workspace
#Path to Source
sonar.sources=/opt/app/jenkins/var/lib/jenkins/jobs/test-BuildJob/workspace/report-api/src, /opt/app/jenkins/var/lib/jenkins/jobs/test1-BuildJob/workspace/test-dao/src, /opt/app/jenkins/var/lib/jenkins/jobs/test1-BuildJob/workspace/test-model/src, /opt/app/jenkins/var/lib/jenkins/jobs/test-BuildJob/workspace/test-frontend/src
My jenkins job runs in different workspace.
/opt/app/jenkins/var/lib/jenkins/jobs/TestJob/jobs/test-SonarAnalysis
How do i configure sonar to run the analysis in given sonar.projectbasedir?

groovy script for using MSTEST jenkins plugin to generate test report

I am using Jenkins MSBUILD plugin in a Freestyle project which is just fine. I have to specify the location of .TRX file and the test report gets generated.
Now I want to use groovy command so I can take advantage of Jenkins pipeline. can someone help me with batch/groovy command to use .TRX as a input and generate test report in Jenkins UI? I tried below but no success.
mstest.exe /publishresultsfile:"C:\Path_to_file\TestResult.TRX"
Below error occurs
Invalid switch "/publishresultsfile".

Link to SonarQube on Jenkins job not available

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).

Error in Executing Jobs on Slave In Jenkins

I have Master Slave configuration under Jenkins.I wanted to run a job on the slave system under Jenkins I order to do that I have copied the required scripts and files But I have been getting the following error
Started by user anonymous
[EnvInject] - Loading node environment variables.
Building remotely on MySlave in workspace C:\Users\prathamesh.n\workspace\MasterSlave
FATAL: Cannot find executable from the chosen Ant installation "apache-ant-1.9.4"
Build step 'Invoke Ant' marked build as failure
Archiving artifacts
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at PROJECT level C:\Users\sudharshan.r\workspace\Ant\exec\reports\Test 1 to C:\Users\sudharshan.r.jenkins\jobs\Project 11\htmlreports\HTML_Report
ERROR: Specified HTML directory 'C:\Users\sudharshan.r\workspace\Ant\exec\reports\Test 1' does not exist.
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: C:/Users/sudharshan.r/workspace/Ant/exec/reports/Test 1/testng-results.xml
Did not find any matching files.
[BFA] Scanning build for known causes...
[BFA] Done. 0s
Finished: FAILURE
need help on executing ant on slave
Click on Jenkins - > Manage Jenkins -> configure system -> Under Ant, define your installer and then in your job select that ant configuration.
Whats your configuration in your build? Default or let's assume my 1.9.
Now in "configure jenkins": Add a specific ant e.g. with name my 1.9.
easiest way is automatic installation and installation from Apache
if you don't want to do this: uncheck automatic installation and give your path were you installed ant in the field: ANT_HOME

Resources