How to successfully run selenium test script in jenkins? - jenkins

I've configured my project to run the Build with Jenkins.
If I execute the testng.xml on my own it successfully executes my test case but if I execute via Jenkins I get the following error message:
Error: Could not find or load main class ûcp Build step 'Execute Windows batch command' marked build as failure Finished: FAILURE

Related

Groovy script works in console but not in job

So I've created a Groovy script, and it works in the console. I then implemented it into my job in the field Execute Groovy Script but then it failed.
Here I have the console, and I do know the imports aren't needed, but I had to try.
But When I run my job with this code, I get this error:
Running as SYSTEM
[EnvInject] - Loading node environment variables.
Building remotely on Buildsl (hant) in workspace C:\JS\workspace\node_checker
[Vetus_node_checker] $ groovy C:\JS\workspace\node_checker\hudson633049885410603886.groovy
Caught: groovy.lang.MissingPropertyException: No such property: Jenkins for class: hudson633049885410603886
groovy.lang.MissingPropertyException: No such property: Jenkins for class: hudson633049885410603886
at hudson633049885410603886.run(hudson633049885410603886.groovy:6)
Build step 'Execute Groovy script' marked build as failure
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE
It look like you are using the "Execute Groovy script", but to execute scripts like in Script Console you must use the "Execute system Groovy script" step.
The normal execute will start a new Java/JVM with Groovy which is not "connected" to your Jenkins.
Only the system step will execute the script within the existing Java/JVM that is running Jenkins.
So yes I had to run it as a Execute system Groovy script, but I also had to give the full path to the lib I'm using, before it worked. the Script Console didn't need the jenkins.model... part, but the job does.

Automated Deployement Build Failed in Jenkins

I am doing automated deployemnt in jenkins and getting error saying that:
Build step 'Execute Windows batch command' marked build as failure.
Building on master in workspace:
C:\Program Files (x86)\Jenkins\workspace\AutomatedDeployement1
[AutomatedDeployement1] $ cmd /c call C:\Windows\TEMP\jenkins1993620515430909066.bat
C:\Program Files (x86)\Jenkins\workspace\AutomatedDeployement1>date
The current date is: 08-06-2020
Enter the new date: (dd-mm-yy)
C:\Program Files (x86)\Jenkins\workspace\AutomatedDeployement1>exit 1
Build step 'Execute Windows batch command' marked build as failure
[DeployPublisher][INFO] Build failed, project not deployed
Finished: FAILURE
Your answer will help me in learning. Thanks In advance
The "marked build as failure" message happens because of the exit code in your batch file. Try exit 0 instead of exit 1.
You can also instruct Jenkins to continue building even though there was a build error.

Jenkins can't find directory when executing shell command

I want to execute these shell command in my Jenkins job.
cd /Users/username/Desktop/JenkinsProject
javac Jenkins.java
java Jenkins
However when I try to build I get the error:
Running as SYSTEM
Building in workspace /Users/Shared/Jenkins/Home/workspace/JenkinsExample
[JenkinsExample] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/jenkins2459427386874444762.sh
+ cd /Users/username/Desktop/JenkinsProject
/Users/Shared/Jenkins/tmp/jenkins2459427386874444762.sh: line 2: cd: /Users/username/Desktop/JenkinsProject: Not a directory
Build step 'Execute shell' marked build as failure
Gitcolony notification failed - java.lang.IllegalArgumentException: Invalid url:
Finished: FAILURE
It looks like it can't find the folder when running the commands with Jenkins?
If I dont use Jenkins but run the commands in my terminal everything works fine.

Jenkins fails Jest tests that otherwise works (corporate proxy)

I am sitting behind corporate proxy.
So basically test is just page.goto("https://") I created Freestyle project and made it execute code in command line:
cd C:/Testing
npm test -- Jenkins
If I run these commands on machine where Jenkins is running, everything works and test passes. However, if I run it using Jenkins, this error appears:
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Main Project
[Main Project] $ cmd /c call C:\Windows\TEMP\jenkins7770552654778169643.bat
C:\Program Files (x86)\Jenkins\workspace\Main Project>cd C:/Testing
C:\Testing>npm test -- Jenkins
> testing#1.0.0 test C:\Testing
> jest "Jenkins"
FAIL .\Jenkins.test.js (5.023s)
Describe
× Test (513ms)
� Describe › Test
net::ERR_TUNNEL_CONNECTION_FAILED at https://google.com/
at navigate (node_modules/puppeteer/lib/Page.js:539:37)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 6.587s
Ran all test suites matching /Jenkins/i.
npm ERR! Test failed. See above for more details.
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
I checked Jenkins HTTP Proxy Configuration and it was set up correctly (host, port and credentials are all correct), but if I enter https://google.com/ in Test URL and press "Validate Proxy", this error appears:
Failed to connect to https://google.com/ (code 407).
Is there something that can refuse Jenkins requests to websites? Windows Defender firewall is disabled.

Build Failure while integrating Jenkins with HP ALM

Created a Build for running Selenium Maven Scripts through jenkins and publish Results in HP ALM.
Steps I follow:-
1.Add ALM ServerName and ALM URL under Configure System>> Manage Jenkins
2.Add Build Step>> Execute HP Functional Tests from HPALM
Added the test Set Value as Root\TestSet\TestSetFolder
3.Add Post Build Action>>Publish HP Tests Result>> Reports archive Mode
4.Add>>Upload Test Result to ALM
Testing Frameowrk = Junit, Test Folder = "TestSet\TestSetFolder\TestCaseName ,Test Set Folder = "TestSet\TestSetFolder, Testing result file ="**/junitResult.xml
5. Run the Build and getting the Failure whereas my particular selenium scripts get passed. Below is the Error for Console Output.
I had the same problem, that was because of "\" which were escaped by Jenkins. I don't why. If you remove them and always have a bad path you should have a trace like that :
Run mode is set to: RUN_PLANNED_HOST
Could not find TestSet Subject/Scenario/BAD_PATH/TEST_SET
================================================
Run status: Job failed, total tests: 0, succeeded: 0, failures: 0, errors: 0
================================================
Build step 'Execute HPE functional tests from HPE ALM' changed build result to FAILURE
Finished: FAILURE
Personnaly I solved the problem replacing "\" by "\\".

Resources