Running Jmeter from execute shell on Jenkins - command-line

After building the maven projects I'd like to run the jmeter tests independently. I go to the jmeter bin folder and execute:
jmeter -n -t $jmxFile -l $jtlFile
but I get the error:
/tmp/hudson2322728548480325736.sh: line 7: jmeter: command not found
Build step 'Execute shell' marked build as failure
What commands can I use?
Say I have the jmx files under one particular folder. If there is another way to run these tests, please let me know.
Thanks in advance.

Ensure jmeter is on user running jenkins path.
Another option is to put the full path to jmeter.
A third one to use maven plugins, see:
What maven plugin is to be used for JMeter? jmeter-maven-plugin or chronos-jmeter-maven-plugin?

you can also checkout how we added JMeter tests to Jenkins:
http://ibalosh.tumblr.com/post/35475979058/running-jmeter-tests-with-jenkins
might help
Igor

Related

Jmeter (JMX) running on GIThub) encounters an error

I tried to run my JMX file on Github however I'm encountering an error. can someone help me fix this. Your response is highly appreciated. Thank you.
PerfAction for Jmeter
Screenshot:
YAML File
Your test plan is using Dummy Sampler and your JMeter installation doesn't have this Dummy Sampler plugin installed.
Make sure to add it using JMeter Plugins Manager (it can also be done in command-line mode) and this error will go away.
If your script uses other JMeter Plugins - do the same for all the plugins used.

Why does Jenkins change my workspace path?

i have installed Jenkins on Windows 10 and each time i try to execute a maven project or just try to execute mvn clean test (command line), Jenkins decides that my new workspace should be: C:\Windows\system32\config\systemprofile\eclipse-workspace\ while my project is in C:\Users\username\eclipse-workspace.
Jenkins starts in the directory C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins.jenkins\workspace\projectName and even if i run a cd command i will have this problem:
The driver executable must exist:
C:\Windows\system32\config\systemprofile\eclipse-workspace\projectname\drivers\chromedriver\chromedriver.exe
My chrome driver is not there obviously but it's in C:\Users\userName\eclipse-workspace\projectName\drivers\chromedriver.
It looks like than Jenkins changes my user.home.
I went to config file and set:
<workspaceDir>C:\Users\userName\eclipse-workspace</workspaceDir>
but it's still looking for the driver in C:\Windows\system32\config\systemprofile\eclipse-workspace\projectname\drivers\chromedriver\chromedriver.exe
This part: C:\Windows\system32\config\systemprofile\ is obtained using in Java System.getProperty("user.home"). Running it with Jenkins seems to modify it.
Why is it looking for my driver there?
Why can't it just stick to my workspace folder?
How can i solve this?
Thank you
I think i solved it. I was running under Local System Account
https://jenkins-le-guide-complet.github.io/html/sect-windows-service.html#fig-hudson-windows-service-config
I had edit the service as shown in the link.

Getting java.awt.HeadlessException after run gui tests on Jenkins

After running gui tests on Jenkins I am getting java.awt.HeadlessException on build Jenkins:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
I am using xvfb in pipeline Jenkins (script), eclipse & maven.
How coud I solve this issue via Jenkins file (script) or maven pom or in another way?
Why am I getting this exception?
Somewhere in your pipeline you probably need to have export DISPLAY=:0.0 or something similar.

Why don't my artifacts published during the build using the publishArtifacts service message show up in TeamCity?

I am creating a screenshot when my NUnit end-to-end test fails and I am trying to publish it with TeamCity (build agent and server both running on Windows) using the following service message (as described here) which I am writing with Console.WriteLine from an NUnit test:
##teamcity[publishArtifacts 'C:\BuildAgent\work\xxxxxxxxxxxxxxxx\Path\To\My\Stuff\fail.png']
I see the line in the build log:
------- Stdout: -------
##teamcity[publishArtifacts 'C:\BuildAgent\work\xxxxxxxxxxxxxxxx\Path\To\My\Stuff\fail.png']
But TeamCity is not picking up the file, or at least it is not showing up in the build artifacts. How do I make this work?
Try using relative paths. Teamcity should resolve them against build working directory.
You can try Console.Write instead of Console.WriteLine (see below).
Anyway, I guess TeamCity don't trap these messages because they are 'test reports' and appended in the buildlog as text output.
My feeling is they are not parsed and then not interpreted by the Build Script Interaction behavior because of the way they are flushed into the build log.
From the Build Script Interaction (TC 7) :
Service messages are used to pass commands/build information to
TeamCity server from the build script. In order to be processed by
TeamCity they should be printed into standard output stream of the
build (otherwise, if the output is not in the service message syntax,
it should appear in the build log). A single service message should
not contain a newline character inside it, it should not span across
multiple lines.
You should put your test artifacts in a specific folder and delay the publish after the tests.
Note that if you don't need to resolve artifact dynamically, you should use the simpliest way : the Artifact paths in the build configuration general settings.
Use the NuGet package provided by JetBrains, this takes care of all the subtleties
NuGet Install TeamCity.ServiceMessages
On GitHub: https://github.com/JetBrains/TeamCity.ServiceMessages

TeamCity can't find NAnt

I am trying to call a NAnt script from TeamCity, but I'm encountering something that makes no sense to me.
I've tested the NAnt script from the command line and it works perfectly.
I've configured the NAnt build runner in TeamCity, and when I run it, I get the following error:
Step 3/3
The following paths do not contain NAnt:
C:\nant\bin
C:\TeamCity6\buildAgent\work\59c8c293c5dec971\C:\nant\bin
Please check "NAnt home" parameter at the build runner settings page
I've checked many times that the NAnt executable resides in C:\nant\bin
Am I missing something?
Check to make sure the user that team city is running as has permission to that file...
You should have everything you need to build your project (NAnt included) in your repository (Eg. in build\tools folder). Everyone should be able to build after check-out without installing tools.