Jmeter+Jenkins Parameters - jenkins

I am trying to run jmeter(.jmx) file using Jenkins by passing Number of Threads as a Parameter. Build getting success but .jmx file is not running. And also not showing any error in console.Following are my setup
In Jmeter Thread properties --Number of thread (Users)- ${__P(USERS,1)
In Jenkins job Created build string parameter -- USER_COUNT
Build using Execute shell and following is my command
cd /apache-jmeter-2.13/bin
./jmeter.sh -n -t /jmxFiles/Jbpm6Rest3Jenkins1.jmx -l /jmxFiles/SIP.jtl -JUSERS=%USER_COUNT%
While starting build passing USER_COUNT value from Jenkins
Following is the Jenkins console output
Jenkins Console Output
Not sure where i am doing wrong.
Note: Not using Ant/Maven to run jmx file.

As the other answer mentioned, change the %_USER_COUNT% to ${USER_COUNT}.
But is there any specific reason you are not using Ant/Maven?
Eventhough you should be able to run your jmeter test using a simple shell script, using Ant/Maven might make your life easier while generating report, charts etc.
I would advise you check the below links.
http://www.testautomationguru.com/jmeter-continuous-performance-testing-part1/
http://www.testautomationguru.com/jmeter-continuous-performance-testing-part2/

From the output, seems you are running a shell build step ($ /bin/sh -xe ....), which means your Jenkins runs on Linux (?). Also the paths use forward slash (/)....
You should put the string ${USER_COUNT} as part of your command (%USER_COUNT% is windows style).
I hope this helps.

Related

Passing Thread Properties in Taurus YAML JMeter

I am trying to build a Taurus yaml file for the below Jmeter scenarios, I have 2 threads where I am passing the Number Of Threads and Duration. Now with the regular command line, I use the below command to start the script, I use this same command from Jenkins too. This works fine and generate reports but not blazemeter one, so i am trying Taurus integration...
nohup /ssd/jmeter/apache-jmeter-5.3/bin/jmeter3g -Jquoteoff.threads=20 -Jquote.threads=20 -n -t /ssd/jmeter/scripts/PerformanceTesting/src/PS/OFFLINE_ONLINE.jmx
My below YML give me error, i am not sure if i am missing anything.
execution:
- scenario:
properties:
quote.threads: 20
quoteoff.threads: 20
onduration: 3600
script: /ssd/jmeter/scripts/PerformanceTesting/src/PS/OFFLINE_ONLINE.jmx
Also is there any direct command like shell we can use to invoke this script? I have seen a few places directly calling JMX script in Jenkins but not sure how to pass parameters in that scenarios.
I have no clue what's wrong here but below line is what causing the failure when i am trying to run bzt script.jmx
log.debug( vars.get("QUOTE_ID"));
To fix it when I changed log.debug to log.info it fixed the below problem I was facing. This is the partial answer as i am not sure about the reason for failure, but this should solve an issue where the script runs fine in Jmeter but bzt gives an error for XML parsing.
Wouldn't that be easier to add BlazeMeter Uploader plugin to your JMeter test plan, the plugin can be installed using JMeter Plugins Manager
It's possible to run existing .jmx script without creating any YAML
bzt /path/to/your/test.jmx
The correct syntax to define properties is:
execution:
- scenario: simple
scenarios:
simple:
script: tests/jmx/dummy.jmx
properties:
quote.threads: 20
#etc
Parameters can be passed via -o command-line argumententer link description here

Jenkins script execution and output display

I'm trying to execute several scripts located in our Linux directories and display the script's output (preferably) as console output.
So far, I have created a project for this task, selected execute shell from Add Build Step and write in the script path from the vm it is located in. The build passes successfully, but I do not see any output on console output, so I'm not sure if the script works or not.
Any ideas on this matter would be appreciated a lot.
Here is the solution I have used.
I selected "Execute Shell" form "Add Build Step" and wrote down my command with the following syntax:
/usr/bin/ssh user#machinename.com "uname -a; id; cd /home/user; ./script1; ./script2.sh"
Apart from the command I've written above, I shared the ssh keys of "user" with the remote machine that it is going to connect via ssh so that a session opens up with auto login and without prompting for password.
Second key point was the " " marks when I've put my command in between.
For displaying the output in Console Output part, this feature works by default and in addition to it, I've installed Email Extension plugin which sends out a mail containing Console Output after every build.

Jenkins + CasperJS

I have a series of frontend tests written in CasperJS that I need to run in Jenkins. Here is command I run from the command line: casperjs test ./src/tests/**/ts_*.js --xunit=xunit.xml. This runs the tests and saves the xunit file. Ok. When I have Jenkins run the same command it gets through loading the first test page and spits out this error: "Process leaked file descriptors" and directs me to: https://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build
It provides an explanation and a few OS specific work arounds. The environment this will be run on will eventually be linux however my development environment is Windows and I don't understand the workaround they provide. What kind of file is that and how does it fit with Jenkins?
Does anyone have experience running CasperJS tests using Jenkins?
I installed jenkins as a service and use default settings.
I solved same issue on windows.
if you are running as a service and default home directory ( c:/program files(x86)/jenkins/ )
you have to change path to other normal folder(ex.c:/jenkins/").
SET JENKINS_HOME=c:\jenkins\
What I do with jenkins and casper:
I create a job with string parameter 'tests', which takes *.js or specified test
and try to run casper tests via Build -> Execute shell
cd ~/test_directory
casperjs test ${tests}

Parameterized build Jenkins

I have configured a job in Jenkins and checked "This build is parameterized" option. The parameter name I have given is "My_Param". The Jenkins is installed in the server machine. So I access the Jenkins dashboard through http://<servername>:8080/ In the Build part, I have to call a script by opening cygwin. So I write
#!C:\cygwin\bin\bash --login -i
./build/myscript.sh -full
After the build is completed, I want to move the files to another new directory prefix with Output, This directory name is the parameter I intend to pass. so I write
mkdir /cygdrive/c/users/admin/Ouput$My_Param
I run the build and pass param as first
But, the directory is created as Output in the server machine and not as Outputfirst
Since you noted you use cygwin, I understand the server is on windows.
Try parameter windows style environment variable: %My_Param% or linux: ${My_Param}
I hope this helps.

execute shell step skipped completely in jenkins

I can't seem to run a build execute shell step in Jenkins. I've worked with Hudson in the past on windows and I was able to create shell/batch steps without a problem but I seem to be be missing something here.
It's a fresh jenkins install and I go to "add build step", "execute shell" and enter "echo hi" in the command. I run the build and when I look in the console output, nothing happens.
I've also tried executing a test.sh file which also just echoes hi. I've tested this in both a linux install and an os X installed Jenkins server.
What am I missing in the configuration to run a shell script?
The console output shows that the shell script steps were skipped completely
Started by user admin
Finished: SUCCESS
It looks like Jenkins is not being able to redirect the output from the system. What version of Java are you using? If you're using OpenJDK, could you try with Sun Java/Sun JDK?
First test to try to check if anything is executing at all: add the following to your "Execute Shell"
#!/bin/bash
echo "HELLO WORLD" > /tmp/testfile
Run this and check if there is a /tmp/testfile in on your Linux system, and if it contains the HELLO WORLD text, it means your script is in fact executing.
Which version of Jenkins do you have?
The last good version that I can attest to (last one I know works well at least for us) is 1.447. If you're not using that one, would you be able to try with it?
Also, could you add #!/bin/sh or #!/bin/bash before echo hi on your "Execute Shell" for the Linux system and see if that works.
Also, try running a script using source /path/to/script and see if that works. The script should contain #!/bin/sh or #!/bin/bash as the first line, just to see if that makes a difference.
Note: none of this should be required, but is helpful just to get more information on what's going on. Couldn't fit all this into a comment. I'll update my answer based on your answers to the above, or delete if I can't get anything..
Putting this here for posterity.
I had a Jenkins project configured with Maven running clean test and a execute shell in the pre steps. The logs from Maven where not coming through and the script was not executing. Once I unchecked Build modules in parallel under the Maven build options my logs and scripts started working.
Make sure its in a location where Jenkins can see it, check permissions.

Resources