SonarQube Scanner analysis skipped in travis CI - analysis

Does anyone knows for which reasons a SonarQube Scanner analysis could be skipped ?
$ sonar-scanner -X -Dsonar.host.url=https://sonarqube.com -Dsonar.login=$SONAR_TOKEN
08:59:10.162 INFO: Scanner configuration file: /home/travis/.sonarscanner/sonar-scanner-2.8/conf/sonar-scanner.properties
08:59:10.166 INFO: Project root configuration file: /home/travis/build/armadito/glpi/plugins/armadito/sonar-project.properties
08:59:10.182 INFO: SonarQube Scanner analysis skipped
The command "sonar-scanner -e -X -Dsonar.host.url=https://sonarqube.com -Dsonar.login=$SONAR_TOKEN" exited with 0.

Finally, I found out that travis-ci's sonarqube addon set by itself the following environnment variable :
export SONARQUBE_SKIPPED=true
With the following message :
Skipping SonarQube Scan because this branch is not master or it does not match declared branches
Indeed, I was working on a different branch: DEV.
Thus, the solution is the following, in .travis.yml :
sonarqube:
branches :
- DEV
And in sonar-project.properties :
sonar.branch=DEV

I have added branch under addons in travis.yml and also sonar branch in sonar properties file, but still SonarQube analysis gets skipped. how to fix this?
addons:
sonarqube:
token:
secure: "XXXXXXXXXXXXXXXXXXXXXXXXXX"
branches :
develop
added in travis.yml
and in sonar-project.properties, I have added this key as well
sonar.branch=develop
but travis has always this
$ export SONARQUBE_SKIPPED=true
0.41s$ sonar-scanner
INFO: Scanner configuration file: /home/travis/.sonarscanner/sonar-scanner-2.8/conf/sonar-scanner.properties
INFO: Project root configuration file: /home/........../sonar-project.properties
INFO: SonarQube Scanner analysis skipped

Related

TFS - GitVersion - A supported task execution handler was not found

I have on-prem TFS 2015, and want to run gitversion, so added step as below:
GitVersion.yml:
mode: Mainline
branches:
feature:
mode: ContinuousDeployment
tag: rc
increment: Minor
source-branches:
- master
fix:
mode: ContinuousDeployment
tag: rc
increment: Patch
regex: ^fix[/-]
bug:
mode: ContinuousDeployment
tag: rc
increment: Patch
regex: '(bug(fix(es)?)?|support)[/-]'
source-branches:
- master
upgrade:
mode: ContinuousDeployment
tag: rc
increment: Major
regex: '(upgrade|major)[/-]'
source-branches:
- master
Build agent is on windows server, installed GitVersion
dotnet tool install --global GitVersion.Tool --version 5.*
But pipeline fails
2022-11-10T11:43:24.9727477Z ##[section]Starting: gitversion/execute
2022-11-10T11:43:24.9934703Z ==============================================================================
2022-11-10T11:43:24.9934703Z Task : Execute GitVersion Task
2022-11-10T11:43:24.9934703Z Description : Easy Semantic Versioning (http://semver.org) for projects using Git
2022-11-10T11:43:24.9934703Z Version : 0.9.15
2022-11-10T11:43:24.9934703Z Author : GitTools Contributors
2022-11-10T11:43:24.9934703Z Help : See the [documentation](https://gitversion.net/docs/) for help
2022-11-10T11:43:24.9934703Z ==============================================================================
2022-11-10T11:43:25.4018670Z ##[error]A supported task execution handler was not found. This error usually means the task does not carry an implementation that is compatible with your current operating system. Contact the task author for more details.
2022-11-10T11:43:25.4018670Z ##[section]Finishing: gitversion/execute
On build machine downloaded gitversion to C:\GitVersion folder then on CI/CD pipeline added task execute command
C:\GitVersion\GitVersion.exe /output buildserver /nofectch

Jenkins Finished: FAILURE after Katalon test

I am trying using Jenkins to run Katalon test but I have failure when finish katalon test.
here detail what i have done:
Run Test on Katalon it's work fine no error,
jenkins Failed After runing Katalon test,
Change Jenkinsfile Script with chrome no-sanbox (error)
if you have idea what going on here or find what I miss please let me know, I have work on this few days but still no clue.
here details of my Jenkinsfile, I have declare all variable before.
stage ("Regression Test") {
echo 'regression test'
node ('kre-centos') {
cleanWs deleteDirs: true
checkout scm: [$class: 'GitSCM', userRemoteConfigs: [[credentialsId: 'ci-cd', url: "${katalonRepoUrl}"]], branches: [[name: "${katalonBranch}"]]]
withCredentials([string(credentialsId: 'katalon-api-key', variable: 'secret')]) {
echo "workspace : ${workspace}"
sh """
pwd
ls
/katalon01/katalon-studio-engine/katalonc -noSplash -runMode=console \
-projectPath='${workspace}/${katalonProjectName}' -retry=0 \
-testSuiteCollectionPath="Test Suites/${katalonTestSuiteName}" \
-executionProfile="default" -browserType="Chrome (headless)" \
-apiKey=${secret}
"""
}
}
}
Here details of jenkins log
+ pwd
/katalon01/jenkins-agent/workspace/Framework/framework-katalon
+ ls
build.gradle
console.properties
debug.log
FRM-Katalon.prj
Include
Object Repository
Profiles
Scripts
settings
Test Cases
Test Suites
+ /katalon01/katalon-studio-engine/katalonc -noSplash -runMode=console -projectPath=/katalon01/jenkins-agent/workspace/Framework/framework-katalon/FRM-Katalon.prj -retry=0 '-testSuiteCollectionPath=Test Suites/FRM_Katalon' -executionProfile=default '-browserType=Chrome (headless)' -apiKey= 8490e2f6-9949-4610-b043-*******
Katalon workspace folder is set to default location: /tmp/session-f1cdbf48
Starting Groovy-Eclipse compiler resolver. Specified compiler level: unspecified
177 2.4.7.xx-2016111****-e46 = ACTIVE
INFO: Katalon Version: 7.5.2
INFO: Command-line arguments: -runMode=console -projectPath=/katalon01/jenkins-agent/workspace/Framework/framework-katalon/FRM-Katalon.prj -retry=0 -testSuiteCollectionPath=Test Suites/FRM_Katalon -executionProfile=default -browserType=Chrome (headless) -apiKey=******** 8490e2f6-9949-4610-b043-********
INFO: User working dir: /katalon01/jenkins-agent/workspace/Framework/framework-katalon
INFO: Error log: /tmp/session-f1cdbf48/.metadata/.log
INFO: Katalon TestOps server URL: https://analytics.katalon.com
INFO: Katalon Store server URL: https://store.katalon.com
INFO: User home: /katalon01/jenkins-agent
INFO: Java vendor: Oracle Corporation
INFO: Java version: 1.8.0_262
INFO: Local OS: Linux 64bit
INFO: CPU load: 0%
INFO: Total memory: 7316 MB
INFO: Free memory: 1013 MB
Start getting machine ID on Linux
End getting machine ID on Linux c05973d029ca9e78c8*******
Start appending additional signatures
hardwareSerialNumber
osDependentUsername jenkins
End appending additional signatures c05973d029ca9e78c8d1437*****__jenkins
INFO: Machine ID: 6546c254cb38a5280********
Activating...
Start activating offline...
Search for valid offline licenses in folder: /katalon01/jenkins-agent/.katalon/license
The number of valid offline licenses: 0
Offline activation failed.
Start activating online...
Cleaning up workspace
Opening project file: /katalon01/jenkins-agent/workspace/Framework/framework-katalon/FRM-Katalon.prj
Warning! Please run Katalon execution command outside of the project folder.
Generating global variables...
Parsing custom keywords...
Project 'FRM-Katalon' opened
Start reloading plugins...
Katalon version: 7.5.2
Plugin info URL: https://store.katalon.com/api/products/ks?appVersion=7.5.2&appType=ENGINE&licenseType=ENTERPRISE
Start check license task
chromedriver is located at default location: /katalon01/katalon-studio-engine/configuration/resources/drivers/chromedriver_linux64/chromedriver. In case your browser is updated to a newer version, please use this command to update chromdriver: --config -webui.autoUpdateDrivers=true
--------------------------------------------------------------------------------
Test Suites/FRM_Katalon - 20200814_092512................................0/7(0%)
--------------------------------------------------------------------------------
Test Suites/Test Suite_Application Controller - Chrome - 20200814_092512.0/7(0%)
--------------------------------------------------------------------------------
Launcher status after execution process completed: Running
Start writing execution.uuid file to folder: /katalon01/jenkins-agent/workspace/Framework/framework-katalon/Reports/20200814_092512/Test Suite_Application Controller/20200814_092512
Start generating JUnit report folder at: /katalon01/jenkins-agent/workspace/Framework/framework-katalon/Reports/20200814_092512/Test Suite_Application Controller/20200814_092512...
JUnit report were generated at folder: /katalon01/jenkins-agent/workspace/Framework/framework-katalon/Reports/20200814_092512/Test Suite_Application Controller/20200814_092512
--------------------------------------------------------------------------------
Test Suites/FRM_Katalon - 20200814_092512...............................4/7(57%)
--------------------------------------------------------------------------------
Test Suites/Test Suite_Application Controller - Chrome - 20200814_092512........
........................................................................4/7(57%)
--------------------------------------------------------------------------------
Uploading report to Katalon TestOps...
Start sending test result to Katalon TestOps
Uploading log files of test suite collection
Sending file: /katalon01/jenkins-agent/workspace/Framework/framework-katalon/Reports/20200814_092512/Test Suite_Application Controller/20200814_092512/execution.uuid
Sending file: /katalon01/jenkins-agent/workspace/Framework/framework-katalon/Reports/20200814_092512/Test Suite_Application Controller/20200814_092512/execution0.log
Sending file: /katalon01/jenkins-agent/workspace/Framework/framework-katalon/Reports/20200814_092512/Test Suite_Application Controller/20200814_092512/execution.properties
Sending file: /katalon01/jenkins-agent/workspace/Framework/framework-katalon/Reports/20200814_092512/Test Suite_Application Controller/20200814_092512/JUnit_Report.xml
Sending file: /katalon01/jenkins-agent/workspace/Framework/framework-katalon/Reports/20200814_092512/FRM_Katalon/20200814_092512/JUnit_Report.xml
Sending file: /katalon01/jenkins-agent/workspace/Framework/framework-katalon/Reports/20200814_092512/FRM_Katalon/20200814_092512/20200814_092512.rp
--------------------------------------------------------------------------------
Test Suites/FRM_Katalon - 20200814_092512..............................7/7(100%)
--------------------------------------------------------------------------------
Test Suites/Test Suite_Application Controller - Chrome - 20200814_092512........
.......................................................................7/7(100%)
--------------------------------------------------------------------------------
Katalon TestOps: Start uploading report to Katalon TestOps server: https://analytics.katalon.com
Katalon TestOps - Execution URL: https://analytics.katalon.com/from-ks/execution-result?teamId=50***&projectId=62***&id=6941***
End sending to Katalon TestOps
Report has been sent to Katalon TestOps
--------------------------------------------------------------------------------
Test Suites/FRM_Katalon - 20200814_092512..............................7/7(100%)
--------------------------------------------------------------------------------
Test Suites/Test Suite_Application Controller - Chrome - 20200814_092512........
.......................................................................7/7(100%)
--------------------------------------------------------------------------------
Execution completed. Exit code: 1.
Start clean up session
End check license task
End clean up session
Start release license task
License released
End release license task
All launchers terminated
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Posting build status of FAILED to bitbucketERROR: script returned exit code 1
Finished: FAILURE
Here details of Katalon error log
2020-08-14 08:40:21 - [TEST_CASE][FAILED] - Test Cases/Application Controller/TS-001_Login Logout Positive Case: Test Cases/Application Controller/TS-001_Login Logout Positive Case FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to open browser with url: 'http://10.172.**.***:3000/'
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword.openBrowser(OpenBrowserKeyword.groovy:81)
at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword.execute(OpenBrowserKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:72)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.openBrowser(WebUiBuiltInKeywords.groovy:60)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$openBrowser.call(Unknown Source)
at TS-001_Login Logout Positive Case.run(TS-001_Login Logout Positive Case:19)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:169)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:142)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:91)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1597394411452.run(TempTestSuite1597394411452.groovy:37)
Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'devopstools-katalon', ip: '10.172.**.***', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1127.el7.x86_64', java.version: '1.8.0_262'
Driver info: driver.version: CChromeDriver
remote stacktrace: #0 0x55edd4eed*** <unknown>
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:19))
at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword$_openBrowser_closure1.doCall(OpenBrowserKeyword.groovy:74)
at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword$_openBrowser_closure1.call(OpenBrowserKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
... 19 more
Try updating your Chrome options with
ChromeOptions options = new ChromeOptions();
...
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
as suggested here.
UPDATE:
To switch from Katalon keywords to Selenium commands use the DriverFactory library. Add this to the top of your script:
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
System.setProperty("webdriver.chrome.driver", "C:\\test\\chromedriver.exe")
ChromeOptions options = new ChromeOptions()
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
WebDriver driver = new ChromeDriver(options)
DriverFactory.changeWebDriver(driver)
For more information see here.

SonarQube Scanner fails in a Jenkins pipeline due to command not found

I'd like to run SonarQube Scanner from a Jenkins pipeline and I followed the documentation.
Regarding the error, it seems that the scanner is present but some commands are not found. My jenkins instance runs in a docker.
Jenkins version : 2.46.1
SonarQube Scanner : 2.6.1
+ /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner/bin/sonar-scanner
/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner/bin/sonar-scanner: line 56: which: command not found
/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner/bin/sonar-scanner: line 66: exec: : not found
In the sonar-scanner script, there is this block
if [ -n "$JAVA_HOME" ]
then
java_cmd="$JAVA_HOME/bin/java"
else
java_cmd="$(which java)"
fi
And given that my JAVA_HOME was unset, the script called which and the command is not installed inside my container.
As a workaround, I set the env variable JAVA_HOME.
Make sure the PATH is complete, or check if resetting it is enough
def sonarqubeScannerHome = tool name: 'SonarQubeScanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation'
withEnv(["PATH=/usr/bin: ..."]) {
// Your call to Sonar
sh "${sonarqubeScannerHome}/bin/sonar-scanner -e -Dsonar.host.url=..."
}
I used the setup from "Execute SonarQube Scanner within Jenkins 2 Pipeline", but with Sonar 2.5, there is an official support of Jenkins pipeline:
def scannerHome = tool 'SonarQube Scanner 2.8';
withEnv(["PATH=/usr/bin: ..."]) {
withSonarQubeEnv('My SonarQube Server') {
sh "${scannerHome}/bin/sonar-scanner"
}
}

Sonar in Jenkins 2 Pipeline - missing global config

I try to run sonar tests with maven in my Jenkins pipeline project. The documentations says if the sonar is configured globally and you use the withSonarQube step the environment variables with the globally configured sonar properites are injected. So far so good.
http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzingwithSonarQubeScannerforMaven
My pipeline config looks like:
def stash = '********'
def branch = 'dev'
stage('git') {
node {
git branch: branch, credentialsId: 'Buildserver-Private.key', url: stash
}
}
stage('build') {
node {
//....
}
}
stage('sonar') {
node {
withSonarQubeEnv('Sonar') {
sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar'
}
}
}
The build fails because the sonar plugin trys to connect to the default h2 database instead of the configured one. If i check the log, there are no sonar properties passed to maven.
Injecting SonarQube environment variables using the configuration: Sonar
[Pipeline] {
[Pipeline] tool
[Pipeline] sh
[***********] Running shell script
+ cd .
+ /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3_3_9/bin/mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar
[INFO] Scanning for projects...
[...]
[INFO] --- sonar-maven-plugin:3.2:sonar (default-cli) # *******.project.build ---
[INFO] User cache: /var/lib/jenkins/.sonar/cache
[INFO] SonarQube version: 4.5.6
[INFO] Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
12:23:17.971 INFO - Load global referentials...
12:23:18.071 INFO - Load global referentials done: 102 ms
12:23:18.102 INFO - User cache: /var/lib/jenkins/.sonar/cache
12:23:18.109 INFO - Install plugins
12:23:18.176 INFO - Install JDBC driver
12:23:18.183 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
Why is my config ignored? What does the documentation mean if it says?
Since version 2.5 of the SonarQube Scanner for Jenkins, there is an
official support of Jenkins pipeline. We provide a 'withSonarQubeEnv'
block that allow to select the SonarQube server you want to interact
with. Connection details you have configured in Jenkins global
configuration will be automatically passed to the scanner.
It seems they are not ...
Has anybody an idea what am I missing?
You are using an old version of SonarQube (4.5.6, the previous LTS) that requires to pass DB connection parameters (URL, login, password) to the scanners - which is a security issue. withSonarQubeEnv does not propagate those settings in order to fix this flaw.
Since SonarQube 5.2, these parameters are no longer required. So you have to use a version that is more recent. I suggest you to upgrade to the latest LTS version of SonarQube (5.6).

Casperjs export XML to Jenkins

I successfully setup a casperjs test exporting a "result.xml" file.
In Jenkins, I execute the following shell command:
casperjs /home/testing-radu/generated-test.js
This produces "results.xml" in my build's workspace.
In post-build actions I added "Publish XUnit test result report". I don't know how and where to setup the path to the .xml file.
When my build console I see the following:
[37;42;1mPASS 2 tests executed in 9.96s, 2 passed, 0 failed. [0m
[32;1mResult log stored in results.xml [0m
[xUnit] [INFO] - Starting to record.
ERROR: Publisher org.jenkinsci.plugins.xunit.XUnitPublisher aborted due to exception
/var/lib/jenkins/jobs/17live2/workspace/generatedJUnitFiles does not exist.
I added full rights to the workspace directory. I tried creating "generatedJUnitFiles" folder and here is what I'm getting:
[37;42;1mPASS 2 tests executed in 5.296s, 2 passed, 0 failed. [0m
[32;1mResult log stored in results.xml [0m
[xUnit] [INFO] - Starting to record.
[xUnit] [INFO] - Setting the build status to FAILURE
[xUnit] [INFO] - Stopping recording.
Build step 'Publish xUnit test result report' changed build result to FAILURE
Finished: FAILURE
Am I missing something?
Allright, here's the deal:
Under publish XUnit test results I chose JUnit (also setup the pattern to *.xml) and then
created a shell script to be executed by Jenkins:
# Auth tests
for f in auth/*.js ; do casperjs "$f"; done;
# Clean the old results and place the new ones
rm /var/lib/jenkins/jobs/17live2/workspace/*.xml
mv *.xml /var/lib/jenkins/jobs/17live2/workspace/
In Jenkins config I just do: ./run.sh
***You need read/write rights over your folders.

Resources