Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins with the Measurement Plots plugin does not plot measurements

Is there anyone who was successful in getting a plot using Jenkins with the Measurement Plots plugin and a xUnit test results file with the tags?

If yes, I'd like to see a sample of a working xUnit file and get from you any tips you may have about configuring Jenkins and the appropriate Jenkins job to accomplish this feat.

like image 351
Omer Zak Avatar asked Sep 26 '11 19:09

Omer Zak


1 Answers

I just figured it out with some help from the author. The trick is to escape the XML inside the XML and use <system-out>to feed the Measurements Plot plugin. The steps below shows how to use it and feed various values into the plugin:

  1. Create a New Job in Jenkins "free-style software project"
  2. Add String Parameter VALUETEST
  3. Add Build step Execute Shell Command is the code below.
  4. Add Post-build Action: Publish JUnit
    1. Test report XMLs: testdetail-*.xml
    2. Check Retain long staandard output
    3. Check Measurement Plots
  5. Save and Build Now.
  6. Plot will appear under Test Results. You need more than one run for the plot appear.

Execute Shell Command:

echo '<?xml version="1.0" encoding="UTF-8"?>' > testdetail-lcov.xml
echo '<testsuites name="CodeAnalysis" tests="2" failures="0" disabled="0" errors="0" time="0">' >> testdetail-lcov.xml

echo '<testsuite  name="Suite" tests="1" >' >> testdetail-lcov.xml
echo '<testcase   name="Case" status="run" time="0" classname="Suite">' >> testdetail-lcov.xml
echo '</testcase></testsuite>' >> testdetail-lcov.xml

echo '<testsuite  tests="1" >' >> testdetail-lcov.xml
echo '<testcase   name="Lcov" status="run" time="0" classname="CodeAnalysis.Coverage">' >> testdetail-lcov.xml

echo '<system-out>' >> testdetail-lcov.xml
echo "&lt;measurement&gt;&lt;name&gt;Line Coverage&lt;/name&gt;&lt;value&gt;$VALUETEST&lt;/value&gt;&lt;/measurement&gt;" >> testdetail-lcov.xml
echo '</system-out>' >> testdetail-lcov.xml

echo '</testcase></testsuite></testsuites>' >> testdetail-lcov.xml
like image 65
MattiasF Avatar answered Oct 26 '22 04:10

MattiasF