Why jenkins can not perform certain names of jmx? - jenkins

1.It can't perform when my script name is lotteryOnline:
2.But changed to other names (such as game), BUILD SUCCESSFUL:

Most likely your JMeter test execution for this lotteryOnline test plan has failed. The reason of failure you can see in the jmeter.log file. If you don't see the log file you can add jmeterlogfile parameter to jmeter Ant task like:
<jmeter
jmeterhome="${jmeter.home}"
testplan ="${testpath}/${test}.jmx"
resultlog="${testpath}/${test}.jtl"
jmeterlogfile="/path/to/jmeter.log"> <!-- add this line to enable logging-->
References:
JMeter Ant Task
Five Ways To Launch a JMeter Test without Using the JMeter GUI

Because there is a file, which is called game.itl. The parameter where you supply game is used to pick that file, as it seems.

Related

Jtl file is empty when running Jmeter using ant

I am trying to run Jmeter with ant, (since I want to display the results of test, with all the steps).
The issue is that after I managed to run the command the Jtl file is empty, I am trying to run the basic test.jmx default test.
I run the command ant -Detest=Test run
the build is successful but the jtl results are empty. moreover it is finished after one second, while if I run via UI mode it should take more time.
Can someone please advise how to use ant with Jmeter, or how to get fully reports like in csv in html out put?
[][build results]
[][build.xml from ant\bin location]
[][location of test.jtl results file]
[][results are empty]
Most probably something is wrong with your JMeter test itself, i.e.
JMeter failed to start (installation or configuration issues)
it has 0 threads in Thread Group
there is an If Controller condition which prevent test execution
the test relies on a JMeter Plugin which is not installed
etc.
So I would recommend amending your build.xml file and enable writing JMeter log file by adding the next line to <jmeter> section: jmeterlogfile="${testpath}/jmeter-ant.log >
So it would look like
<jmeter
jmeterhome="${jmeter.home}"
testplan ="${testpath}/${test}.jmx"
resultlog="${testpath}/${test}.jtl"
jmeterlogfile="${testpath}/jmeter-ant.log>
When you run your test one more time you should see jmeter-ant.log file in the folder where your .jmx file lives.
More information: JMeter Ant Task

Jmeter with ant - reports creation

I am trying to create report using ant in jmeter, meaning the full report.
I downloaded ant and it is installed as expected.
first I want to understand if ant command need to perform after test plan ran in the past? meaning it is offline process that creates the html reports? after the test plan finished?
Or is it command that actually used to run the test plan and create the html, meaning I do not need to run jmeter before?.
I used this command
jmeter -n -t C:\JMETER\Framework\Test_Fragment\Kung_Fu.jmx -l C:\Users\stackoverflow\Desktop\Jmeter_reports\results22_05_2018.csv
to run jmeter from command line, and create csv, so do I need two commands? one for creating csv and one for the ant? and if I create the csv where can I find the jtl of the testplan.
Name of test plan kung_fu
name of csv results22_05_2018.csv
what are the processes to run he ant, since I rename the Kung_Fu.jmx to test.jmx and put it in extras folder and when I command ant, it says test.jtl is not found.
can someone give a full explanation about the whole process
Rename results22_05_2018.csv into results22_05_2018.jtl and copy it to "extras" folder of your JMeter installation
Execute the following command in "extras" folder of your JMeter installation:
ant -Dtest=results22_05_2018 xslt-report
HTML report will be available as results22_05_2018.html
For more details see:
build.xml - reference Ant build file, by default it:
looks for Test.jmx file in the current folder
executes it and stores the result into Test.jtl file
applies XSLT transformation to the Test.jtl file and generates HTML file out of it.
JMeter Ant Task
Five Ways To Launch a JMeter Test without Using the JMeter GUI

how to scan test source code with the SonarQube Jenkins plugin?

I'm trying to make a Jenkins job that only scans the test source files, so everything under /src/test/java (using Maven). I use the SonarQube Jenkins post-action for this.
When we used to configure Sonar in the pom file directly we could do this in a profile:
<sonar.sources>/src/test/java</sonar.sources>
<sonar.tests/>
That worked fine.
But in the Jenkins job I have to specify these as 'Additional properties' and I can't seem to specify an emtpy sonar.tests element. I tried -Dsonar.tests, -Dsonar.tests=,-Dsonar.tests="", nothing works. When this element is not empty Sonar will attempt to scan the test files twice and crash.
The post-build step is specifically and explicitly a Maven operation. Your problem comes from trying to use Maven to do something un-Mavenish; i.e. ignore the convention that files in the tests directory should be treated as tests.
Since you want to scan your tests as code, your best bet is to use the build step (which uses SonarQube Scanner) and set your scanner properties manually. That will make it easy to set your sources directory and to omit the tests directory.

Retrieval of Jenkins environment variables while invoking ANT

I am invoking a windows batch command from Jenkins, after i get the latest version of my project from SVN. the windows batch command just performs certain file copying, after the all the files are retrieved from SVN and runs an ANT build. In the ANT build process, i am generating a JSP file where i have tried to capture the in the following fashion.
%BUILD_TAG%-%BUILD_NUMBER%-%BUILD_ID%-%SVN_REVISION%
Unfortunately none of this information is understood by the build process and it just writes %BUILD_TAG%-%BUILD_NUMBER%-%BUILD_ID%-%SVN_REVISION% into the file.
Could you please let me know if there is a way to capture these information into a file in the way i am trying to do? if not, could you direct me on how these information could be captured into a JSP file during the process that we are following?
BUILD_TAG, SVN_REVISION, etc are all environment variables that are present during a Jenkins build, and to use them in Ant, you would use them as any other environment variable from Ant
First, add a line:
<property environment="env"/>
Then you can reference any environment variable with this prefix, like:
${env.VAR_NAME}
So in your case, you'd do:
${env.BUILD_TAG}-${env.BUILD_NUMBER}-${env.BUILD_ID}-${env.SVN_REVISION}

How do i pass parameters from Jenkins to Ant scripts?

For some GUI testing I'm creating a Jenkins task for each GUI module to be tested.
Once created I'm using Ant to build these tests, but I'm not aware of how to actually pass parameters from Jenkins to Ant build file? Basically how do I do variable substitution in Ant?
I'm using the Sahi framework to test GUI components, so the flow goes like this...
Jenkins → Ant build script → Sahi file to execute
Can anyone please take a look at it?
"Using ant -Dname=value lets you define values for properties on the Ant command line." http://ant.apache.org/faq.html#passing-cli-args
To use a jenkins parameter as a variable when you call any use ${variablename}
https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build
Click Advance under configure section of your job in jenkins and use "Properties" section to pass parameter value to Ant script.
e.g
jenkins.param=10
ant.prop=$jenkins.param where jenkins.param is the parameter defined in the jenkins job .
Now in your ant build script ,you can get the value by using ${ant.prop}.
From Jenkins to SAHI Pro via ANT.
In the ant target that you call from Jenkins, give the following within sahi tag.
<customfield key="variable_name" value=" variable _value"/>
Now, such values from Jenkins will be available in SAHI Pro through the ant target. To retrieve them in SAHI, you should set them in “CUSTOM_FIELDS” of testrunner file.
For example:
SET CUSTOM_FIELDS= -variable_name jenkinsToSahiVariable
Where -variable_name should be same key that you set in ant target. And second string will contain the value you set from Jenkins. To get this in a sahi file, use sahiSuite API like following.
$jenkinsValues = _suiteInfo();
$sahiVariable = $ jenkinsValues ["jenkinsToSahiVariable"];

Resources