title: Infinite loop in Jelly script for Jenkin's email-ext plugin. Why?
body: <p>I'm trying to use the email-ext plugin in Jenkins to send an email containing all of the changes since the last successful build. I've pieced together the following, replacing the change set portion of the default html.jelly script, but it goes into an infinite loop. I don't see why, and I'm not sure how I'd debug it. I have never written a Jelly script before, so there is probably something simple in here.</p>
  
  <pre><code>&lt;j:set var="changesBuild" value="${build.previousNotFailedBuild}" /&gt;
  &lt;j:if test="${changesBuild!=null}"&gt;
    &lt;j:set var="changesBuild" value="changesBuild.nextBuild" scope="parent" /&gt;
  &lt;/j:if&gt;
  &lt;j:if test="${changesBuild==null}"&gt;
    &lt;j:set var="changesBuild" value="build" scope="parent"  /&gt;
  &lt;/j:if&gt;
  
  &lt;j:while test="${changesBuild!=null}"&gt;
    &lt;j:set var="changeSet" value="${changesBuild.changeSet}" /&gt;
    &lt;j:if test="${changeSet!=null}"&gt;
    &lt;j:set var="hadChanges" value="false" /&gt;
      &lt;TABLE width="100%"&gt;
      &lt;TR&gt;&lt;TD class="bg1" colspan="2"&gt;&lt;B&gt;CHANGES&lt;/B&gt;&lt;/TD&gt;&lt;/TR&gt;
      &lt;j:forEach var="cs" items="${changeSet}" varStatus="loop"&gt;
        &lt;j:set var="hadChanges" value="true" /&gt;
        &lt;j:set var="aUser" value="${cs.hudsonUser}"/&gt;
        &lt;TR&gt;
          &lt;TD colspan="2" class="bg2"&gt;${spc}Revision &lt;B&gt;${cs.commitId?:cs.revision?:cs.changeNumber}&lt;/B&gt; by
            &lt;B&gt;${aUser!=null?aUser.displayName:cs.author.displayName}: &lt;/B&gt;
            &lt;B&gt;(${cs.msgAnnotated})&lt;/B&gt;
           &lt;/TD&gt;
        &lt;/TR&gt;
        &lt;j:forEach var="p" items="${cs.affectedFiles}"&gt;
          &lt;TR&gt;
            &lt;TD width="10%"&gt;${spc}${p.editType.name}&lt;/TD&gt;
            &lt;TD&gt;${p.path}&lt;/TD&gt;
          &lt;/TR&gt;
        &lt;/j:forEach&gt;
      &lt;/j:forEach&gt;
      &lt;j:if test="${!hadChanges}"&gt;
        &lt;TR&gt;&lt;TD colspan="2"&gt;No Changes&lt;/TD&gt;&lt;/TR&gt;
      &lt;/j:if&gt;
      &lt;/TABLE&gt;
      &lt;BR/&gt;
    &lt;/j:if&gt;
    &lt;j:set var="changesBuild" value="changesBuild.nextBuild" scope="parent" /&gt;
  &lt;/j:while&gt;
  </code></pre>
  
  <p>Email-ext has a CHANGES_SINCE_LAST_SUCCESS token, but I don't see a way to make that available when trying to send nice HTML emails</p>