Gatling fails on jenkins when run multiple job on multiple executor - jenkins

I'm using gatling version 2.1.6 with jenkins plugins annd without maven, my scenario are launch with execute shell
#!/bin/bash
if [ ! -f "novapostme/jenkins/${JOB_NAME}.scala" ]; then
exit 1
fi
${GATLING_HOME}/bin/gatling.sh -df ${WORKSPACE}/novapostme/datas -rf ${WORKSPACE} -sf ${WORKSPACE} -s ${JOB_NAME}
Is each job is run alone on onlly one executor (useing blocking jobs options) all is working well, but when I run multiple job on executors I have sometimes this type of error
[workspace] $ /bin/bash /tmp/hudson6410661655551326741.sh
GATLING_HOME is set to /opt/gatling-charts-highcharts-2.1.6
Exception in thread "main" java.lang.NoClassDefFoundError: MeDocumentDownload
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at io.gatling.app.classloader.FileSystemBackedClassLoader.findClass(FileSystemBackedClassLoader.scala:71)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at io.gatling.app.classloader.SimulationClassLoader$$anonfun$simulationClasses$1.applyOrElse(SimulationClassLoader.scala:57)
at io.gatling.app.classloader.SimulationClassLoader$$anonfun$simulationClasses$1.applyOrElse(SimulationClassLoader.scala:57)
at scala.collection.immutable.List.collect(List.scala:303)
at io.gatling.app.classloader.SimulationClassLoader.simulationClasses(SimulationClassLoader.scala:57)
at io.gatling.app.Gatling.loadSimulations(Gatling.scala:92)
at io.gatling.app.Gatling.start(Gatling.scala:70)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:59)
at io.gatling.app.Gatling$.main(Gatling.scala:44)
at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: java.lang.ClassNotFoundException: MeDocumentDownload
at io.gatling.app.classloader.FileSystemBackedClassLoader.findClass(FileSystemBackedClassLoader.scala:70)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 14 more
Build step 'Execute shell' marked build as failure
Build step 'Groovy Postbuild' marked build as failure
Archiving Gatling reports...
No newer Gatling reports to archive.
Finished: FAILURE
The question is : is it possible to run simultaneous jobs on mutiple executor ?

Related

Jenkins run a shell command when build is failed as a post build action to run failed TestNG plan

I want to rerun, below shell script in the same project, once my build is i completed with errors, so I can rerun my failed test cases in testng-failed.xml.
FILE=./target/surefire-reports/testng-failed.xml
if test -f "$FILE"; then
echo "$FILE exists."
mvn clean test -Dhttp.proxyHost=proxy-dev.aws.skynet.com -Dhttp.proxyPort=8080 -Dproxy-dev.aws.skynet.com -Dhttps.proxyPort=8080 -Dbrowser="${Browser}" -Dbrowser_version="${browser_version}" -Dos_version="10" -Dos="Windows" -Dlocalrun="false" -Dtestxml=FILE
else
echo "$FILE is not there"
fi
But in Jenkins, post build section, I don't see an option to add Execute shell. Please help.
I installed post build plugin , but it's only show for maven projects and not for my free style project.
In free style project, No post steps option.
I managed a walkaround to do this without any plugins and still run in the Jenkins free style project. Add two execute shells and in first shell enter the below shell commands.
export M2_HOME=/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven3
export PATH=$PATH:$M2_HOME/bin
mvn --version
cd CommonPagesStorage
mvn clean install -DskipTests
cd ..
cd MultiWebdriverDemo
mvn clean test -Dmaven.test.failure.ignore=true -Dsurefire.suiteXmlFiles=TestSuites/${TestPlanName}
echo "${TestPlanName}is ran"
#Dmaven.test.failure.ignore=true added this so even the script failed it doesn't mark as fail and mark it as unstable and continue.
In the second shell command ,conditionally checks the testng-failed.xml is exists if so run it to run the failed test cases.
cd MultiWebdriverDemo
export M2_HOME=/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven3
export PATH=$PATH:$M2_HOME/bin
mvn --version
#this to print current directory.
echo "the second Script executed from: ${PWD}"
if [ -e ./target/surefire-reports/testng-failed.xml ]
then
echo "ok file found pass"
mvn test -Dmaven.test.failure.ignore=true -Dsurefire.suiteXmlFiles=target/surefire-reports/testng-failed.xml
else
echo "file not found passed in first attempt ..."
exit 0
#exit 0 means forcefully mark it as passed
fi
if [ -e ./target/surefire-reports/testng-failed.xml ]
then
echo "Rerun also failed exiting with buil state as failure "
exit 1
#exit 1 means forcefully mark it as failed
else
echo "file not found rerun is passed marking the build as passed ..."
exit 0
fi
S0 even in the second time, my webdriver test case is failed, it's failed build mark as a failure.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.199 s
[INFO] Finished at: 2021-08-12T14:05:36Z
[INFO] ------------------------------------------------------------------------
+ [ -e ./target/surefire-reports/testng-failed.xml ]
+ echo Rerun also failed exiting with buil state as failure
Rerun also failed exiting with buil state as failure
+ exit 1
Build step 'Execute shell' marked build as failure
Archiving artifacts
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/testng-results.xml
Saving reports...
Processing '/var/jenkins_home/jobs/August-FreeStyle/builds/37/testng/testng-results.xml'
100.000000% of tests failed, which exceeded threshold of 0%. Marking build as UNSTABLE
TestNG Reports Processing: FINISH
Finished: FAILURE

execute groovy script in jenkins job

I am quite new in Jenkins and I am trying to run groovy script 'println "hello world" ' in jenkins. But i am getting below error.
[Test] $ groovy /var/jenkins_home/workspace /Test/hudson481621137087598172.groovy
FATAL: command execution failed
java.io.IOException: Cannot run program "groovy" (in directory "/var/jenkins_home/workspace/Test"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:249)
at hudson.Proc$LocalProc.<init>(Proc.java:218)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:935)
at hudson.Launcher$ProcStarter.start(Launcher.java:454)
at hudson.Launcher$ProcStarter.join(Launcher.java:465)
at hudson.plugins.groovy.Groovy.perform(Groovy.java:106)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1815)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 15 more
Build step 'Execute Groovy script' marked build as failure
Finished: FAILURE
I have found some solution Run groovy scripts in Jenkins but I am not sure how can i use that in my case.
You need to add path to your groovy binaries in Jenkins -> Manage Jenkins -> Global Tool Configuration. Once you install groovy on your machine provide path to it's installation folder. For example on my machine it's like shown on the picture below:
Before checking your Global Tool Configuration in Jenkins, you might try installing/updating your Homebrew installation and run "brew install groovy" first. This will enable you to set the groovy home path (http://macappstore.org/groovy/). Otherwise Jenkins may not save you Tool Configuration properly.
You should set GROOVY_HOME:
export GROOVY_HOME=/usr/local/opt/groovy/libexec

Build step failed with exception using build timeout plugin

I have requirement to implement CI.Following are jenkins configuation details:
Jenkins server 32-bit (window 7)
Maven Integration plugin(version3.0)
Ant Plugin(Version 1.7)
Build Timeout(Version 1.19)
SQLPlus Script Runner( version 1.0.9)
Subversion Plug-in (Version 2.9)
I have following job configutaion:
Configure SVN Repository in Source Code Management step
On Build Environment ->Pre Steps -> using build timeout plugin->Sql script runner for oracle database.
When I executed the job i received following error but if i tried to excute Sql script runner without using build timeout it run smoothly :
ERROR: Build step failed with exception
java.lang.ClassCastException: hudson.maven.MavenModuleSetBuild cannot be cast to hudson.model.Build
at hudson.plugins.build_timeout.BuildStepWithTimeout.perform(BuildStepWithTimeout.java:73)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.build(MavenModuleSetBuild.java:945)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:683)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:496)
at hudson.model.Run.execute(Run.java:1737)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)
Build step 'Run with timeout' marked build as failure
Finished: FAILURE
I have tried build timeout with ant script same error message is coming.Please suggest.
Thank you.

Jenkins deploy WAR in glassfish

I want deploy in Glassfish a WAR using these batch commands from Jenkins. :
This is how I deploy a WAR with Batch command :
H:\workspace\xxxx>"C:\glassfish3\glassfish\bin\asadmin.bat" "undeploy"
Enter the value for the name operand> xxxx
H:\workspace\xxxx>"C:\glassfish3\glassfish\bin\asadmin.bat" "deploy"
Enter the value for the path operand> H:\xxxx-sources\xxxx.war
Application deployed with name xxxx.
Command deploy executed successfully.
In Jenkins , I add a batch command in my build with that :
cd "C:\glassfish3\glassfish\bin\"
asadmin.bat "undeploy"
XXXX
asadmin.bat "deploy"
H:\XXXX sources\XXXX.war
I have this error :
Démarré par l'utilisateur anonymous Building on master in workspace
C:\Documents and
Settings\XXXX.XXXX.jenkins\jobs\deployerXXXXCore\workspace
[workspace] $ sh -xe
C:\DOCUME~1\XXXX~1.XXXX\LOCALS~1\Temp\hudson2065869118895930371.sh
The system cannot find the file specified FATAL: L'exécution de la
commande a échoué. java.io.IOException: Cannot run program "sh" (in
directory "C:\Documents and
Settings\XXXX.XXXX.jenkins\jobs\deployerXXXX\workspace"):
CreateProcess error=2, The system cannot find the file specified at
java.lang.ProcessBuilder.start(ProcessBuilder.java:460) at
hudson.Proc$LocalProc.(Proc.java:244) at
hudson.Proc$LocalProc.(Proc.java:216) at
hudson.Launcher$LocalLauncher.launch(Launcher.java:802) at
hudson.Launcher$ProcStarter.start(Launcher.java:380) at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:97)
at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at
hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at hudson.model.Build$BuildExecution.build(Build.java:199) at
hudson.model.Build$BuildExecution.doRun(Build.java:160) at
hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:533)
at hudson.model.Run.execute(Run.java:1759) at
hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at
hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240) Caused by:
java.io.IOException: CreateProcess error=2, The system cannot find the
file specified at java.lang.ProcessImpl.create(Native Method) at
java.lang.ProcessImpl.(ProcessImpl.java:81) at
java.lang.ProcessImpl.start(ProcessImpl.java:30) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:453) ... 15 more
Build step 'Exécuter un script shell' marked build as failure
Finished: FAILURE
It seems that you are trying to execute your scripts in Jenkins using shell script execution,which works only on unix-like systems. Try doing the same with Windows batch execution in the Jenkins job.
You should select 'Execute Windows batch command' according to Jenkins guide.

Jenkins Post Build Task does not work when job is aborted

I have an issue about Post Build Task after an job abort (manual or timeout): the abort generates a java.lang.InterruptedException which seems to be normal. But as Jenkins java machine is stucked how can you run a post task script? I can't.
here is the java exception:
#174 aborted
java.lang.InterruptedException
at java.lang.ProcessImpl.waitFor(Native Method)
at hudson.Proc$LocalProc.join(Proc.java:319)
at hudson.Launcher$ProcStarter.join(Launcher.java:345)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:82)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:58)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at
hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:710)
at hudson.model.Build$RunnerImpl.build(Build.java:178)
at hudson.model.Build$RunnerImpl.doRun(Build.java:139)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:480)
at hudson.model.Run.run(Run.java:1438)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:239)
Here is my jenkins output:
Build was aborted
Aborted by admin
Performing Post build task...
Match found for :. : True
Logical operation result is TRUE
Running script : dir
[workspace] $ cmd /c call C:\Users\xxxx\AppData\Local
\Temp\2hudson5872719646331136420.bat
Exception when executing the batch command : null
Build step 'Post build task' marked build as failure
Finished: ABORTED
I ran a bat script on the server that copied all hudson****.bat from the folder (which is cleaned after the job) during the job execution/aborting so I've been able to run cmd /c call C:\xxxx\hudson5872719646331136420.bat manually from the windows run, it worked fine.
thanks for your help

Resources