Jenkins Finished: FAILURE after Katalon test - jenkins

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.

Related

why else block not executing scripted pipeline?

I have this if else statement if the condition is true the if statement executed but if the condition is false the else statement not executed
steps{
script{
echo '*Stage3 - Trying to build python program and export the Artifact*'
pyInstallerOutput = bat(returnStdout: true, script: '#python -m PyInstaller -v').trim()
if(!("$pyInstallerOutput".contains('No module named'))){
echo "+ PyInstaller Version: $pyInstallerOutput is up and running. good! building artifact"
directoryName = bat(returnStdout: true,script: '#echo %date:~-4,4%-%date:~-10,2%-%date:~7,2%-%time:~-11,2%%time:~-8,2%%time:~-5,2%').trim()
echo ("+ Current Artifact directory: $directoryName")
artifactResult = bat(returnStdout: true, script: "#python -m PyInstaller --specpath ./artifacts-repo/${directoryName}/spec --distpath ./artifacts-repo/${directoryName}/dist --workpath ./artifacts-repo/${directoryName}/build --onefile ./codes/SayHello.py")
} else{
echo '- PyInstaller not installed on node, trying to install it'
installResult = bat(returnStdout: true, script: '#pip install pyinstaller')
if("$installResult".contains('Successfully installed')){
echo '+ PyInstaller installed successfully, Now building Artifact.'
directoryName = bat(returnStdout: true,script: '#echo %date:~-4,4%-%date:~-10,2%-%date:~7,2%-%time:~-11,2%%time:~-8,2%%time:~-5,2%')
echo ("+ Current Artifact directory: $directoryName")
artifactResult = bat(
returnStdout: true,
script: "#python -m PyInstaller --specpath ./artifacts-repo/${directoryName}/spec --distpath ./artifacts-repo/${directoryName}/dist --workpath ./artifacts-repo/${directoryName}/build --onefile ./codes/SayHello.py"
)
}else{
error('- PyInstaller installation failed, nothing more can be done by pipeline, STOPING')
}
}
}
}
Log when the if condition is true
*Stage3 - Trying to build python program and export the Artifact*
[Pipeline] bat
[Pipeline] echo
+ PyInstaller Version: 5.5 is up and running. good! building artifact
[Pipeline] bat
[Pipeline] echo
+ Current Artifact directory: 2022-10-09-211243
[Pipeline] bat
376 INFO: PyInstaller: 5.5
376 INFO: Python: 3.10.7
384 INFO: Platform: Windows-10-10.0.22000-SP0
386 INFO: wrote ./artifacts-repo/2022-10-09-211243/spec\SayHello.spec
387 INFO: UPX is not available.
389 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Ata '
'System\\AppData\\Local\\Jenkins\\.jenkins\\workspace\\Pipeline-01\\codes']
840 INFO: checking Analysis
841 INFO: Building Analysis because Analysis-00.toc is non existent
841 INFO: Initializing module dependency graph...
843 INFO: Caching module graph hooks...
854 INFO: Analyzing base_library.zip ...
3125 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\Ata System\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\PyInstaller\\hooks'...
3188 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\Ata System\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\PyInstaller\\hooks'...
4729 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\Ata System\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\PyInstaller\\hooks'...
5910 INFO: Caching module dependency graph...
6004 INFO: running Analysis Analysis-00.toc
6011 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2032.0_x64__qbz5n2kfra8p0\python.exe
6207 INFO: Analyzing C:\Users\Ata System\AppData\Local\Jenkins\.jenkins\workspace\Pipeline-01\codes\SayHello.py
6209 INFO: Processing module hooks...
6219 INFO: Looking for ctypes DLLs
6221 INFO: Analyzing run-time hooks ...
6222 INFO: Including run-time hook 'C:\\Users\\Ata System\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
6224 INFO: Including run-time hook 'C:\\Users\\Ata System\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_subprocess.py'
6228 INFO: Looking for dynamic libraries
365 INFO: Extra DLL search directories (AddDllDirectory): []
366 INFO: Extra DLL search directories (PATH): ['C:\\Program Files (x86)\\VMware\\VMware Workstation\\bin\\', 'C:\\WINDOWS\\system32', 'C:\\WINDOWS', 'C:\\WINDOWS\\System32\\Wbem', 'C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\', 'C:\\WINDOWS\\System32\\OpenSSH\\', 'C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR', 'C:\\Program Files\\Microsoft VS Code\\bin', 'C:\\Program Files (x86)\\Xshell 7\\', 'C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common', 'C:\\Program Files\\Git\\cmd', 'C:\\Users\\Ata System\\AppData\\Local\\Microsoft\\WindowsApps', 'C:\\Program Files\\JetBrains\\PhpStorm 2022.2.1\\bin', 'C:\\xampp\\php', 'C:\\Users\\Ata System\\AppData\\Local\\GitHubDesktop\\bin', 'C:\\apps\\opt\\spark-3.3.0-bin-hadoop3\\bin', 'C:\\apps\\opt\\spark-3.3.0-bin-hadoop3\\bin', 'C:\\Program Files\\Java\\jdk-17\\bin']
7142 INFO: Looking for eggs
7142 INFO: Using Python library C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2032.0_x64__qbz5n2kfra8p0\python310.dll
7142 INFO: Found binding redirects:
[]
7144 INFO: Warnings written to C:\Users\Ata System\AppData\Local\Jenkins\.jenkins\workspace\Pipeline-01\artifacts-repo\2022-10-09-211243\build\SayHello\warn-SayHello.txt
7161 INFO: Graph cross-reference written to C:\Users\Ata System\AppData\Local\Jenkins\.jenkins\workspace\Pipeline-01\artifacts-repo\2022-10-09-211243\build\SayHello\xref-SayHello.html
7188 INFO: checking PYZ
7188 INFO: Building PYZ because PYZ-00.toc is non existent
7188 INFO: Building PYZ (ZlibArchive) C:\Users\Ata System\AppData\Local\Jenkins\.jenkins\workspace\Pipeline-01\artifacts-repo\2022-10-09-211243\build\SayHello\PYZ-00.pyz
7392 INFO: Building PYZ (ZlibArchive) C:\Users\Ata System\AppData\Local\Jenkins\.jenkins\workspace\Pipeline-01\artifacts-repo\2022-10-09-211243\build\SayHello\PYZ-00.pyz completed successfully.
7397 INFO: checking PKG
7398 INFO: Building PKG because PKG-00.toc is non existent
7398 INFO: Building PKG (CArchive) SayHello.pkg
8688 INFO: Building PKG (CArchive) SayHello.pkg completed successfully.
8690 INFO: Bootloader C:\Users\Ata System\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
8690 INFO: checking EXE
8690 INFO: Building EXE because EXE-00.toc is non existent
8690 INFO: Building EXE from EXE-00.toc
8690 INFO: Copying bootloader EXE to C:\Users\Ata System\AppData\Local\Jenkins\.jenkins\workspace\Pipeline-01\artifacts-repo\2022-10-09-211243\dist\SayHello.exe.notanexecutable
8693 INFO: Copying icon to EXE
8694 INFO: Copying icons from ['C:\\Users\\Ata System\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
8705 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
8705 INFO: Writing RT_ICON 1 resource with 3752 bytes
8705 INFO: Writing RT_ICON 2 resource with 2216 bytes
8705 INFO: Writing RT_ICON 3 resource with 1384 bytes
8705 INFO: Writing RT_ICON 4 resource with 37019 bytes
8705 INFO: Writing RT_ICON 5 resource with 9640 bytes
8705 INFO: Writing RT_ICON 6 resource with 4264 bytes
8705 INFO: Writing RT_ICON 7 resource with 1128 bytes
8707 INFO: Copying 0 resources to EXE
8707 INFO: Embedding manifest in EXE
8707 INFO: Updating manifest in C:\Users\Ata System\AppData\Local\Jenkins\.jenkins\workspace\Pipeline-01\artifacts-repo\2022-10-09-211243\dist\SayHello.exe.notanexecutable
8717 INFO: Updating resource type 24 name 1 language 0
8719 INFO: Appending PKG archive to EXE
8732 INFO: Fixing EXE headers
8947 INFO: Building EXE from EXE-00.toc completed successfully.
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] echo
Attemping some cleanup works.
[Pipeline] echo
Log when the if condition not true you can see that the else skipped!!!
*Stage3 - Trying to build python program and export the Artifact*
[Pipeline] bat
C:\Users\Ata System\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe: No module named PyInstaller
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] echo
Attemping some cleanup works.
[Pipeline] echo
you can find the complete jenkins file Here
One option is to surround your bat command with a try-catch or a catchError block
catchError {
pyInstallerOutput = bat(returnStdout: true, script: '#python -m PyInstaller -v').trim()
}

org.sonarqube.ws.client.HttpException: Error 401

I am trying to run sonar-scanner and access quality gate results and am kind of stuck after trying various options suggested on forums. This is my first time trying to post, so please let me know if I am missing any details. I do see the json payload in sonarqube server webhooks console but it is in failed status (red cross-mark). Ours is a shared CBJ and SonarQube server with limited access for me on both of those. Any help/guidance is really appreciated. Thank you so much.
======================================
SonarQube Configuration
Project_Name > Administration > Webhooks
Name: Webhook_Name
URL: https://CloudBeesJenkins_Server_FQDN/dev-master/sonarqube-webhook/
Secret: 'webhook_secret_text'
======================================
CBJ Configuration
CredentialsID: 'SonarQubeToken': Value: Scope: Global credentials (unrestricted)
======================================
Jenkins Job - Pipeline Script
/* this stage succeeds */
stage('SonarQube Analysis') {
def scannerHome = tool 'Sonar-Prod';
withSonarQubeEnv('Sonar-Prod') {
sh """${scannerHome}/bin/sonar-scanner -X \
-Dsonar.projectKey=ProjKey \
-Dsonar.sources=src \
-Dsonar.host.url=https://sonarqube_server_fqdn \
-Dsonar.login=sonar_project_secret_text"""
}
}
/* fails at waitForQualityGate */
stage("Quality Gate Status Check") {
timeout(time: 1, unit: 'HOURS')// Just in case something goes wrong, pipeline will be killed after a timeout
// had previously tried using waitForQualityGate() and waitForQualityGate(webhookSecretId: 'webhook_secret_text' with same result
def qg = waitForQualityGate(webhookSecretId: 'webhook_secret_text', credentialsId: 'sonar_project_secret_text') // Reuse taskId previously collected by withSonarQubeEnv
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
=====================================
Logs from Jenkins Server - Job Running Sonarscanner and qualitygate
SonarQube Scanner 4.2.0.1873
Java 1.8.0_242 Oracle Corporation (64-bit)
Linux 2.6.32-754.27.1.el6.x86_64 amd64
SonarQube server 7.9.1 - Community 7.9.1.27448
[CloudBees Jenkins Enterprise 2.204.3.7-rolling]
09:40:13.671 DEBUG: Upload report
09:40:13.931 DEBUG: POST 200 https://sonarqube_server_fqdn/api/ce/submit?projectKey=ProjKey | time=256ms
09:40:13.935 INFO: Analysis report uploaded in 264ms
09:40:13.938 INFO: ANALYSIS SUCCESSFUL, you can browse https://sonarqube_server_fqdn/dashboard?id=ProjKey
09:40:13.938 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
09:40:13.938 INFO: More about the report processing at https://sonarqube_server_fqdn/api/ce/task?id=AXDt34Wae-uSoUyAgrS-
[Pipeline] waitForQualityGate
Checking status of SonarQube task 'AXDt34Wae-uSoUyAgrS-' on server 'Sonar-Prod'
org.sonarqube.ws.client.HttpException: Error 401 on https://sonarqube_server_fqdn/api/ce/task?id=AXDt34Wae-uSoUyAgrS-
It was a firewall issue. Communication from Jenkins to SonarQube server was opened but not the other way round. This issue can be closed.

SonarQube Scanner analysis skipped in travis CI

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

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