SonarQube in Jenkins pipeline - jenkins

Im new to SonarQube and try for the first time to run it over an .sln file in Jenkins pipeline.
I followed the instructions here and wrote the following commands in a stage:
bat"""
SonarScanner.MSBuild.exe begin /k:"FLT" /d:sonar.login="******" /d:property="C:\\sonar-scanner-msbuild-4.6.2.2108-net46"
MSBuild.exe "${env.Workspace}\\FLT.sln" /t:Rebuild
SonarScanner.MSBuild.exe end /d:sonar.login="******"
"""
After I ren the build I got this error:
SonarQube analysis could not be completed because the analysis configuration file could not be found: C:\Jenkins\workspace\STAR_Dev\Pipelines\FLT GIT\.sonarqube\conf\SonarQubeAnalysisConfig.xml.
So I copied this SonarQubeAnalysisConfig.xml file to the path it shows in the error prior to the SonarScanner.MSBuild.exe part (It copies it during the build). Weirdly it does copy the file but as soon as the SonarCube commands start this file is earased immediatly from that path and the build fails and show the same error.
Any help on how to solve this problem? thanks.

Related

issue in jenkins integration with git

i installed jenkins in c:\program files(x86)\jenkins and am trying to integrate with a helloworld java file. but when i first tried to build from jenkins, itself, its failed.
i went through this link : https://www.youtube.com/watch?v=bGqS0f4Utn4
when i compiled my java file, from the admin cmd prompt, its compiles successfully. but it failed within the jenkins console.
I created a C:\workspace folder and saved the java file, there.
what am doing wrong ? why am getting the wrong path within the console output?
am getting the below error in the console output :
`Console Output
Started by user user1
Running as SYSTEM
[EnvInject] - Loading node environment variables.
Building in workspace C:\Program Files (x86)\Jenkins\workspace\
HelloWorld
[HelloWorld] $ cmd /c call C:\Windows\TEMP\jenkins6223662388306682118.bat
C:\Program Files (x86)\Jenkins\workspace\HelloWorld>cd C:\Workspace
C:\Workspace>javac Hello.java
'javac' is not recognized as an internal or external command,
operable program or batch file.
C:\Workspace>java Hello
'java' is not recognized as an internal or external command,
operable program or batch file.
C:\Workspace>exit 9009
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
First, since you've installed JDK, make sure you've added in system level environment variable
Set JDK bin path in Jenkins > manage jenkins > global tools configurations > jdk installations, then try
mostly this option would help to resolve

How to given Project Path if Jenkins Integration with Git Hub

The below is the command line execution for the automated build to schedule from Jenkins.. This is working fine.
cd C:\Users\3020722\Downloads\Katalon_Studio_Windows_64-5.3.0
katalon.exe -runMode=console -projectPath="C:\Users\3020722\Katalon_Studio\PoC\PoC.prj" -retry=0 -testSuitePath="Test Suites/POCTestSuite" -browserType="IE"
I need to take the latest project from the gitHub... How the workflow for the command line execution.
1. Clone Project in to local directory
2. Use that directory in the command line execution
Is it the case first it needs to clone into always local path (pre-defined) and that path needs to be given. Can you please let me know how the workflow for gitHub to Jenkins
Thanks
You can utilize WORKSPACE variable from Jenkins: https://wiki.jenkins.io/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-belowJenkinsSetEnvironmentVariables
Just put it directly into Katalon Studio command and Jenkins will parse it automatically, e.g:
katalon.exe -runMode=console -projectPath="%WORKSPACE%\PoC.prj" -retry=0 -testSuitePath="Test Suites/POCTestSuite" -browserType="IE"

Jenkins is not able to recognize xmlstarlet in my shell script

I have Jenkins running on my local Windows 7 machine. I am trying to use Jenkins for Salesforce deployment and have added a shell script to parse package.xml. My script uses xmlstarlet to do the parsing, but when I build the project I am getting the following error:
./modifyPackage.bash: line 9: xml: command not found
./modifyPackage.bash: line 24: unexpected EOF while looking for matching `"'
Build step 'Execute shell' marked build as failure
Finished: FAILURE
I am using the git sh.exe to execute the shell script, so I have added the below path in Shell executable.
C:\Program Files\Git\bin\sh.exe
Looks to me that Jenkins is not able to recognize the xml starlet used in shell script. I also tried adding xmlstarlet-1.6 exe file in the GIT directory, but it didn't work. How should I fix this?
Regards
Found out the problem. I needed to add the path of xml starlet as a PATH environment variable in Manage Jenkins -> Configure System -> Global Properties with key as PATH and value as $PATH:$Actual Path of xml starlet.

Jenkins_Execution of gradle script throws a permission denied error

In jenkins iam facing an error when i trigger the gradle task.
When i execute the below shell
cd /home/cucumberBdd
./gradlew cucumber
I got this error ".gradle/1.8/taskArtifacts/cache.properties.lock (Permission denied)"
Below are the configurations:
Os-Ubuntu
CI-Jenkins
Buildtool:Gradle
Script: gradle script
I have installed and mentioned the gradle version in the manage jenkins.
One thing which i noticed is in jenkins the above command + whoam i gives jenkins name but the project folder writes are with system user.Can anyone tell me please how to avoid this error
You should not put .gradle in the version control at all, only the gradle directory (without the dot) needs to be versioned. Everything in .gradle is just caching stuff and can be safely deleted and recreated.

Jenkins + NUnit with TFS on Build Server

I'm new to continuous integration. I'm trying to get Jenkins to execute unit tests from a TFS project. My Jenkins build (pre-NUnit build step) is successful and I've installed the NUnit Jenkins plugin and I've read this post, but it's failing with this error: "The system cannot find the path specified."
I think the trouble is that I'm NOT running from my local machine, so the test DLL that NUnit should be running is missing I think. How can I reference that DLL properly? Do I need an extra Build Step to copy the files or something? Here's my "Execute Windows Batch Command" build step command:
"C:\Program Files\NUnit 2.6.3\bin\nunit-console.exe Victoria.Tests.Integration/bin/Debug/Victoria.Tests.Integration.dll /xml=nunit-result.xml"
The problem is that your command is all in quotes, including the parameters.
Change
"C:\Program Files\NUnit 2.6.3\bin\nunit-console.exe Victoria.Tests.Integration/bin/Debug/Victoria.Tests.Integration.dll /xml=nunit-result.xml"
to
"C:\Program Files\NUnit 2.6.3\bin\nunit-console.exe" Victoria.Tests.Integration/bin/Debug/Victoria.Tests.Integration.dll /xml=nunit-result.xml

Resources