title: How can I get, on a per test case, all robotframework warnings in the email-ext groovy script?
body: <h1>Background</h1>
  <p>Here is a background on the configuration</p>
  <ul>
  <li>I have tests written in Robot Framework</li>
  <li>I am using Jenkins and installed the robotframework and email-ext plugin
  <ul>
  <li>I have a Jenkins job scheduled to run periodically
  <ul>
  <li>The jenkins jobs runs robot tests</li>
  <li>Then sends an email (using email-ext) with the test results</li>
  <li>I am using a groovy script to generate the email content.</li>
  </ul>
  </li>
  </ul>
  </li>
  </ul>
  <p>The groovy script that generates the email content is using the <a href="https://github.com/jenkinsci/robot-plugin/tree/master/src/main/java/hudson/plugins/robot" rel="nofollow noreferrer">robot APIs</a> to get data (e.g.: total tests, total failed, pass percentage) and information about all failed test cases.</p>
  <p>For all failed test cases, a list of RoboCaseResult, I am including:</p>
  <ul>
  <li>Test criticality</li>
  <li>Parent suite</li>
  <li>Test Name</li>
  <li>Error message</li>
  </ul>
  <p>This is currently working.  Here's my Groovy Script achieves this:</p>
  <pre><code>def actionslist = build.actions // List&lt;hudson.model.Action&gt;
  def doRobotResultsExist = false
  actionslist.each() { action -&gt;
      if( action.class.simpleName.equals(&quot;RobotBuildAction&quot;) ) { // hudson.plugins.robot.RobotBuildAction
          doRobotResultsExist = true
          displaycritical = (action.getOverallPassPercentage() != action.getCriticalPassPercentage())
          %&gt;
          &lt;h3&gt;RobotFramework Results&lt;/h3&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;Detailed Report:&lt;/td&gt;
                  &lt;td&gt;&lt;a href=&quot;${rooturl}${build.url}robot/report/&lt;%= action.getLogHtmlLink() %&gt;&quot; target=&quot;_new&quot;&gt;&lt;%= action.getLogHtmlLink() %&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;!--
              &lt;tr&gt;
                  &lt;td&gt;Pass Percentage:&lt;/td&gt;
                  &lt;td&gt;&lt;%= action.overallPassPercentage %&gt;%&lt;/td&gt;
              &lt;/tr&gt;
              --&gt;
              &lt;tr&gt;
                  &lt;td&gt;Overall Pass Ratio:&lt;/td&gt;
                  &lt;td&gt;&lt;%= action.getTotalCount() - action.getFailCount() %&gt;/&lt;%= action.getTotalCount() %&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Pass Percentage:&lt;/td&gt;
                  &lt;td&gt;&lt;%= action.getOverallPassPercentage() %&gt;%&lt;/td&gt;
              &lt;/tr&gt;
              &lt;% 
              if (displaycritical) {
              %&gt;
              &lt;tr&gt;
                  &lt;td&gt;Critical Pass Percentage:&lt;/td&gt;
                  &lt;td&gt;&lt;%= action.getCriticalPassPercentage() %&gt;%&lt;/td&gt;
              &lt;/tr&gt;
              &lt;% } //if displaycrital %&gt;
              
              &lt;tr&gt;
                  &lt;td&gt;Total Failed:&lt;/td&gt;
                  &lt;td&gt;&lt;%= action.getFailCount() %&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;%
          //action.result returns  hudson.plugins.robot.model.RobotResult
          //action.retult.getAllFailedCases() returns a list of hudson.plugins.robot.model.RobotCaseResult
          def allFailedTests = action.result.getAllFailedCases() // hudson.plugins.robot.model.RobotCaseResult
          
          if (!allFailedTests.isEmpty()) {
              i = 0
              %&gt;
              &lt;table cellspacing='0' cellpadding='1' border='1'&gt;
              &lt;tr class='bg1'&gt;
                  &lt;% if (displaycritical) { %&gt;&lt;th&gt;Tagged Critical&lt;/th&gt;&lt;% } //if displaycrital %&gt;
                  &lt;th&gt;Suite&lt;/th&gt;
                  &lt;th&gt;Failed Test Case&lt;/th&gt;
                  &lt;th&gt;Error message&lt;/th&gt;
              &lt;/tr&gt;
              &lt;%
              //allFailedTests.each() { testresult -&gt;
              //    def testCaseResult = testresult
              allFailedTests.each() { testCaseResult -&gt;
                  i++
                  print &quot;&lt;tr &quot; + ( (i % 2) == 0 ? &quot;class='bg2'&quot; : &quot;&quot;) + &quot; &gt;&quot;
                  if (displaycritical) {
                      print &quot;&lt;td&gt;&quot; + (testCaseResult.isCritical()? &quot;&lt;font color='red'&gt;&lt;b&gt;YES&lt;/b&gt;&lt;/font&gt;&quot;: &quot;no&quot; )+ &quot;&lt;/td&gt;&quot;
                  }
                  print &quot;&lt;td&gt;&quot; + testCaseResult.getParent().getRelativePackageName(testCaseResult.getParent()) + &quot;&lt;/td&gt;&quot;
                  print &quot;&lt;td&gt;&quot; + testCaseResult.getDisplayName() + &quot;&lt;/td&gt;&quot;
                  print &quot;&lt;td&gt;&quot; + testCaseResult.getErrorMsg() + &quot;&lt;/td&gt;&quot;
                  print &quot;&lt;/tr&gt;&quot;
              } // for each failed test
              %&gt;
              &lt;/table&gt;
              &lt;%
          } // if list of failed test cases is not empty
      } // end action is RobotBuildAction
  } // end of each actions
  </code></pre>
  <p>This generated something like this</p>
  <pre>
  =========================================================================
  | Tagged Critical | Suite  | Failed Test Case | Error Message           |
  =========================================================================
  |  YES            | Fruits | Get Apples       | Could not get apples    |
  +-----------------+--------+------------------+-------------------------+
  |  NO             | Fruits | Eat Apple        | Could not find an apple |
  =========================================================================
  </pre>
  <h1>The issue</h1>
  <p>For each failed test case, <strong><em>I want to include all WARNING that were raised</em></strong>.  But I'm not able to find an API for this, so I opened an enhancement ticket against the Jenkins plugin.  The Jenkins robotframework plugin maintainer may not reply to my request in the timeframe that I need a solution.</p>
  <p>How can I include, via the groovy script, all the warnings that were raised during a robot test?   That is, I want to get the following</p>
  <pre>
  ================================================================================================
  | Tagged Critical | Suite  | Failed Test Case | Error Message           | Warnings             |
  ================================================================================================
  |  YES            | Fruits | Get Apples       | Could not get apples    | No baskets available |
  +-----------------+--------+------------------+-------------------------+----------------------+
  |  NO             | Fruits | Eat Apple        | Could not find an apple |                      |
  ================================================================================================
  </pre>