Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38968

groovy-html.template: use of member changeSet instead of changeSets

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      While using groovy-html.template inside a pipeline DSL I get the following stack trace sent via eMail:

      Exception raised during template rendering:
      No such property: changeSet for class: org.jenkinsci.plugins.workflow.job.WorkflowRun
      Possible solutions: changeSets
      groovy.lang.MissingPropertyException: No such property: changeSet for class: org.jenkinsci.plugins.workflow.job.WorkflowRun
      Possible solutions: changeSets
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
      at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:66)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
      at SimpleTemplateScript1.run(SimpleTemplateScript1.groovy:33)
      at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:168)
      at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:180)
      at hudson.plugins.emailext.plugins.content.ScriptContent.renderTemplate(ScriptContent.java:127)
      at hudson.plugins.emailext.plugins.content.ScriptContent.evaluate(ScriptContent.java:68)
      at org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.evaluate(DataBoundTokenMacro.java:205)
      at org.jenkinsci.plugins.tokenmacro.Parser.processToken(Parser.java:299) at org.jenkinsci.plugins.tokenmacro.Action$KiHW1UeqOdqAwZul.run(Unknown Source) at org.parboiled.matchers.ActionMatcher.match(ActionMatcher.java:96) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.matchers.SequenceMatcher.match(SequenceMatcher.java:46) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.matchers.FirstOfMatcher.match(FirstOfMatcher.java:41) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.matchers.FirstOfMatcher.match(FirstOfMatcher.java:41) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.matchers.ZeroOrMoreMatcher.match(ZeroOrMoreMatcher.java:39) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.matchers.SequenceMatcher.match(SequenceMatcher.java:46) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.parserunners.BasicParseRunner.run(BasicParseRunner.java:72) at org.parboiled.parserunners.ReportingParseRunner.runBasicMatch(ReportingParseRunner.java:86) at org.parboiled.parserunners.ReportingParseRunner.run(ReportingParseRunner.java:66) at org.parboiled.parserunners.AbstractParseRunner.run(AbstractParseRunner.java:81) at org.parboiled.parserunners.AbstractParseRunner.run(AbstractParseRunner.java:76) at org.jenkinsci.plugins.tokenmacro.Parser.process(Parser.java:68) at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:204) at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:234) at hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:80) at hudson.plugins.emailext.ExtendedEmailPublisher.addContent(ExtendedEmailPublisher.java:718) at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:597) at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:355) at hudson.plugins.emailext.EmailExtStep$EmailExtStepExecution.run(EmailExtStep.java:189) at hudson.plugins.emailext.EmailExtStep$EmailExtStepExecution.run(EmailExtStep.java:129) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52) at hudson.security.ACL.impersonate(ACL.java:221) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) 
      

        Attachments

          Activity

          Hide
          heiko_nardmann Heiko Nardmann added a comment -

          Replacing

          <% def changeSet = build.changeSet
          

          with

          <% def changeSet = build.changeSets
          

          fixes the problem.

          Show
          heiko_nardmann Heiko Nardmann added a comment - Replacing <% def changeSet = build.changeSet with <% def changeSet = build.changeSets fixes the problem.
          Hide
          heiko_nardmann Heiko Nardmann added a comment -

          My last comment has not been complete. My Problem has been that my tests afterwards did not enter the block inside the if statement:

          if(changeSets != null) {
          ...
          

          So now the whole block looks like the following on my part:

          <% def changeSets = build.changeSets
          if(changeSets != null) {
                  def hadChanges = false %>
                  <TABLE width="100%">
              <TR><TD class="bg1" colspan="2"><B>CHANGES</B></TD></TR>
          <%      changeSets.each() { p4ChangeSet ->
                          p4ChangeSet.each() { cs ->
                          hadChanges = true %>
                <TR>
                  <TD colspan="2" class="bg2">&nbsp;&nbsp;Revision <B><%= cs.metaClass.hasProperty('commitId') ? cs.commitId : cs.metaClass.hasProperty('revision') ? cs.revision :
                  cs.metaClass.hasProperty('changeNumber') ? cs.changeNumber : "" %></B> by
                    <B><%= cs.author %>: </B>
                    <B>(${cs.msgAnnotated})</B>
                   </TD>
                </TR>
          <%                      cs.affectedFiles.each() { p -> %>
                  <TR>
                    <TD width="10%">&nbsp;&nbsp;${p.editType.name}</TD>
                    <TD>${p.path}</TD>
                  </TR>
          <%                      }
                          }
                  }
          

          I'm not sure whether this is something Perforce special or Workflow special?

          Show
          heiko_nardmann Heiko Nardmann added a comment - My last comment has not been complete. My Problem has been that my tests afterwards did not enter the block inside the if statement: if(changeSets != null) { ... So now the whole block looks like the following on my part: <% def changeSets = build.changeSets if(changeSets != null) { def hadChanges = false %> <TABLE width="100%"> <TR><TD class="bg1" colspan="2"><B>CHANGES</B></TD></TR> <% changeSets.each() { p4ChangeSet -> p4ChangeSet.each() { cs -> hadChanges = true %> <TR> <TD colspan="2" class="bg2">&nbsp;&nbsp;Revision <B><%= cs.metaClass.hasProperty('commitId') ? cs.commitId : cs.metaClass.hasProperty('revision') ? cs.revision : cs.metaClass.hasProperty('changeNumber') ? cs.changeNumber : "" %></B> by <B><%= cs.author %>: </B> <B>(${cs.msgAnnotated})</B> </TD> </TR> <% cs.affectedFiles.each() { p -> %> <TR> <TD width="10%">&nbsp;&nbsp;${p.editType.name}</TD> <TD>${p.path}</TD> </TR> <% } } } I'm not sure whether this is something Perforce special or Workflow special?
          Hide
          slide_o_mix Alex Earl added a comment -

          You would need to add another layer of .each because getChangesets returns a list of ChangeLogSet (what build.getChangeset returned). So, you would need to iterate through the list outside of the changeSets.each() you have now...

          changeSets.each() {
              changeSet.each() {
                  p4ChangeSet.each() { cs ->
                      ...
                  }
              }
          }
          
          Show
          slide_o_mix Alex Earl added a comment - You would need to add another layer of .each because getChangesets returns a list of ChangeLogSet (what build.getChangeset returned). So, you would need to iterate through the list outside of the changeSets.each() you have now... changeSets.each() { changeSet.each() { p4ChangeSet.each() { cs -> ... } } }
          Hide
          ssbarnea Sorin Sbarnea added a comment - - edited

          Any updates on this? Clearly the current version of groovy-html.template is broken and is not even clear how to workaround it.

          I made a pull request that is supposed to implement those fixes at https://github.com/jenkinsci/email-ext-plugin/pull/158/ but is not tested yet.

          Show
          ssbarnea Sorin Sbarnea added a comment - - edited Any updates on this? Clearly the current version of groovy-html.template is broken and is not even clear how to workaround it. I made a pull request that is supposed to implement those fixes at https://github.com/jenkinsci/email-ext-plugin/pull/158/  but is not tested yet.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Sorin Sbarnea
          Path:
          src/main/resources/hudson/plugins/emailext/templates/groovy-html.template
          http://jenkins-ci.org/commit/email-ext-plugin/dacb2cac7c34c27b27b511e839f7c7050516bc78
          Log:
          Correc use of build.changeSets (#158)

          Fixes wrong variable name in template
          which was failing rendering of template.

          JENKINS-38968

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Sorin Sbarnea Path: src/main/resources/hudson/plugins/emailext/templates/groovy-html.template http://jenkins-ci.org/commit/email-ext-plugin/dacb2cac7c34c27b27b511e839f7c7050516bc78 Log: Correc use of build.changeSets (#158) Fixes wrong variable name in template which was failing rendering of template. JENKINS-38968
          Hide
          davidvanlaatum David van Laatum added a comment - - edited

          Releasing 2.59

          Show
          davidvanlaatum David van Laatum added a comment - - edited Releasing 2.59
          Hide
          ssbarnea Sorin Sbarnea added a comment -

          It seems that yesterday patch did fix the bug for both text and html forms. 

          Here is new one https://github.com/jenkinsci/email-ext-plugin/pull/160

          Show
          ssbarnea Sorin Sbarnea added a comment - It seems that yesterday patch did fix the bug for both text and html forms.  Here is new one  https://github.com/jenkinsci/email-ext-plugin/pull/160
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Sorin Sbarnea
          Path:
          src/main/resources/hudson/plugins/emailext/templates/groovy-text.template
          http://jenkins-ci.org/commit/email-ext-plugin/9cd308d946c18c5e861cef39e31b479acbdd5a30
          Log:
          Jenkins 46818 msg for text template (#160)

          • Correc use of build.changeSets

          Fixes wrong variable name in template
          which was failing rendering of template.

          JENKINS-38968

          • Fixed changeSets in groovy-text.tempalte
          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Sorin Sbarnea Path: src/main/resources/hudson/plugins/emailext/templates/groovy-text.template http://jenkins-ci.org/commit/email-ext-plugin/9cd308d946c18c5e861cef39e31b479acbdd5a30 Log: Jenkins 46818 msg for text template (#160) Correc use of build.changeSets Fixes wrong variable name in template which was failing rendering of template. JENKINS-38968 Fixed changeSets in groovy-text.tempalte

            People

            • Assignee:
              davidvanlaatum David van Laatum
              Reporter:
              heiko_nardmann Heiko Nardmann
            • Votes:
              4 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: