문제

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.

<j:set var="changesBuild" value="${build.previousNotFailedBuild}" />
<j:if test="${changesBuild!=null}">
  <j:set var="changesBuild" value="changesBuild.nextBuild" scope="parent" />
</j:if>
<j:if test="${changesBuild==null}">
  <j:set var="changesBuild" value="build" scope="parent"  />
</j:if>

<j:while test="${changesBuild!=null}">
  <j:set var="changeSet" value="${changesBuild.changeSet}" />
  <j:if test="${changeSet!=null}">
  <j:set var="hadChanges" value="false" />
    <TABLE width="100%">
    <TR><TD class="bg1" colspan="2"><B>CHANGES</B></TD></TR>
    <j:forEach var="cs" items="${changeSet}" varStatus="loop">
      <j:set var="hadChanges" value="true" />
      <j:set var="aUser" value="${cs.hudsonUser}"/>
      <TR>
        <TD colspan="2" class="bg2">${spc}Revision <B>${cs.commitId?:cs.revision?:cs.changeNumber}</B> by
          <B>${aUser!=null?aUser.displayName:cs.author.displayName}: </B>
          <B>(${cs.msgAnnotated})</B>
         </TD>
      </TR>
      <j:forEach var="p" items="${cs.affectedFiles}">
        <TR>
          <TD width="10%">${spc}${p.editType.name}</TD>
          <TD>${p.path}</TD>
        </TR>
      </j:forEach>
    </j:forEach>
    <j:if test="${!hadChanges}">
      <TR><TD colspan="2">No Changes</TD></TR>
    </j:if>
    </TABLE>
    <BR/>
  </j:if>
  <j:set var="changesBuild" value="changesBuild.nextBuild" scope="parent" />
</j:while>

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

도움이 되었습니까?

해결책

I debuged a little and found that the 2nd to the last line:

<j:set var="changesBuild" value="changesBuild.nextBuild" scope="parent" />

You need to remove the scope="parent". and add the ${} around it:

  <j:set var="changesBuild" value="${changesBuild.nextBuild}" />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top