sonar.projectbasedir not working in Jenkins - 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?

Related

How to include CSV file in JMETER running in Jenkins

I am using Jenkins as my deployment pipeline. I have a JMETER project that I will be executing in a build step in Jenkins. That JMETER project has a dependency on a csv file for parameters. How do I get that file included in the Jenkins pipeline and how do I tell JMETER where to look for it in the csv data set config?
I could also do it via a gradle command if that is an option.
Thanks.
The easiest option is running JMeter in command-line non-GUI mode, the relevant Jenkins Pipeline snippet would be:
node {
stage 'Run JMeter Test'
bat 'c:/jmeter/bin/jmeter.bat -n -t c:/jmeter/extras/Test.jmx -l test.jtl'
}
The above setup assumes Windows operating system, if your Jenkins master or build agent is running Linux, Unix or MacOSX - just change bat to sh. You will also need to amend JMeter installation path to reflect your environment. See Running a JMeter Test via Jenkins Pipeline - A Tutorial to see example configuration.
In case of command-line non-GUI mode of JMeter execution you need to copy your CSV file(s) to "bin" folder of your JMeter installation.
In case of using JMeter Ant Task - the same approach, drop your CSV file(s) to JMeter's "bin" folder
In case of JMeter Maven Plugin you will need to copy CSV file(s) to src/test/jmeter folder of your Maven project.
And finally you can just use full path(s) (not relative) to CSV file(s) in CSV Data Set Config elements.

Add SonarQube to jenkins job pipeline failed

At the moment we try to add SonarQube analyzing to our jenkins job pipeline. But every time the build job failed with the message: "java.lang.NoSuchMethodError: **No such DSL method withSonarQubeEnv". We have reinstall all plugins and configurations. Nothing help.
So maybe someone of you can help us.
What we have done:
Do all steps of this tutorial from sonarqube: Analyzing with SonarQube Scanner for Jenkins
Install SonarQube Plugin 2.5
Add and configure SonarQube under Manage Jenkins > Configure System
Add SonarQube Scanner under Manage Jenkins > Global Tool Configuration
Add this code after the checkout of our project to the groovy file for the pipeline:
stage('SonarQube analysis')
// requires SonarQube Scanner 2.8+
def scannerHome = tool 'SonarQube Scanner 2.8';
withSonarQubeEnv('SonarQube 5.6.4') {
sh "${scannerHome}/bin/sonar-scanner"
}
Current Versions of our tools
Our Jenkins has the version 2.2
Our SonarQube Server has the version 5.6.4
The SonarQube Server run fine. We can analyzing our code over a local scanner.
I was trying to test with sonarqube 2.5 plugin but keep getting a different serialization error but have tested the below code which works fine and is without "withSonarQubeEnv" just in case you are looking for alternative:
stage('SonarQube analysis')
// requires SonarQube Scanner 2.8+
def scannerHome = tool 'SonarQube Scanner 2.8';
sh "${scannerHome}/bin/sonar-scanner"
PS: I'll try to test with sonarqube 2.5 plugin and let you know if I find something.

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.

Jenkins Build Flow AND Build Pipeline plugins

Will the Build Pipeline plugin still show the sequence of jobs properly if the jobs are run using Build Flow (including a repeated job)?
Here is pseudocode for our build flow:
build("Package")
build("Deploy", destination: "http://test") // deploy to our test environment
build("IntegrationTests", target: "http://test") // run automated tests
build("Deploy", destination: "http://stage") // deploy to stage
Package will pull code from source control, compile it, and store it as an artifact
Deploy will copy artifacts from the upstream Package job then copy it to the URL provided in the destination parameter
IntegrationTests will run a suite of integration tests against the URL provided in the destination parameter.
Will the Build Pipeline plugin show this pipeline as 4 steps even though the Deploy job is repeated?
Package => Deploy (test) => IntegrationTests => Deploy (stage)
The new solution, which is being adopted with Jenkins 2.0, is the Pipeline plugin. Also, CloudBees open-sourced their Pipeline Stage View plugin which provides a visualization to the Pipeline plugin.

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