emailext jelly template access changetSet

181 views
Skip to first unread message

jer...@bodycad.com

unread,
Oct 17, 2016, 11:06:33 AM10/17/16
to Jenkins Users
Hi,
I have use the Jelly template to re enable most of our email content, except 2 things I still cannot do, the revision change set and the warnings counts (the later is not too bad, we are moving to warnings as errors anyway).

Any body have a way to access the scm changeSet into the pipeline emailext template?

I tried without any luck:
  • ${build.changeSet}
  • ${build.changeSets}
  • ${currentBuild.changeSets}
  • ${manager.build.changeSets}
  • ${manager.build.changeSet}
the console log are accessible with ${build.getLog()}
the artifacts are with ${build.artifacts}

The warning were:
${WARNINGS_RESULT()}
${WARNINGS_COUNT()}
${WARNINGS_NEW()}
${WARNINGS_FIXED()}

but now if used they generate a jelly parsing error.

if any body have any tips or info on this I would be glad,
Thanks
Jerome

touseef

unread,
Oct 19, 2016, 5:56:51 AM10/19/16
to Jenkins Users
May be this code might helped u as i had similar requirement but i implemented it in groovy script

<!-- CHANGE SET -->
<% changeSet = build.changeSet
if (changeSet != null) {
hadChanges = false %>
<h2>Changes</h2>
<ul>
<% changeSet.each { cs ->
hadChanges = true
aUser = cs.author %>
<li>Commit <b>${cs.revision}</b> by <b><%= aUser != null ? aUser.displayName :      it.author.displayName %>:</b> (${cs.msg})
<ul>
<% cs.affectedFiles.each { %>
<li class="change-${it.editType.name}"><b>${it.editType.name}</b>: ${it.path}                              </li> <%  } %> </ul>   </li> <%  }

 if (!hadChanges) { %>  
  <li>No Changes !!</li>
 <%  } %>   </ul> <% } %>

And regarding the count u cant use this
def size= build.changeSet.items.length

jer...@bodycad.com

unread,
Oct 19, 2016, 12:09:22 PM10/19/16
to Jenkins Users
I haven't tested this yet, but does this groovy template work into a pipeline? we used to have a groovy template like this before that did exactly what you propose. Since I wasn't sure how to select the groovy script (now I do, thanks to someone on this forum) and found how to use a jelly template before I converted everything to Jelly. The Jelly equivalent doesn't seem to work. I wonder if this is du to Jelly templating or the pipeline??? If this is the jelly, I will convert back to Groovy, else I will stick to Jelly, the template is cleaner IMO.

Thanks,
Jerome

I will try this and come back on this

Manny DaSilva

unread,
May 25, 2017, 2:12:48 PM5/25/17
to Jenkins Users
I'm in the same situation. Have you found a solution using Jelly? I tried currentBuild.changeSets as described in the doc but it doesn't work in the Jelly template.

Jérôme Godbout

unread,
May 25, 2017, 2:47:44 PM5/25/17
to jenkins...@googlegroups.com
I haven't found the way to make it work into Jelly and did not found time to test Groovy template either sadly :-(

I made many changes manually by a replace function into a copy of the template before sending the template so I probably will be able to replace the changelog with the following pipeline script:

def changeLogSets = currentBuild.changeSets
for (int i = 0; i < changeLogSets.size(); i++) { ... replace into the template file text for each line into html format string...}
Haven't test it yet, but my I already read  file out of my template and replace some variable and write back a temporary template that I send. 

// Replace literal ${VAR} by the map[VAR] entry
def replaceMapIntoStr(str, replace_map)
{
def rv = str;
for(item in replace_map)
{
rv = rv.replace('${' + item.key + '}', item.value);
}
return rv;
}

As matter of fact I assemble multiple template part based on the current build result and steps done.

bodycad
Jerome Godbout
Software Developer
2035 rue du Haut-Bord, Québec, QC, Canada. G1N 4R7
T:  +1 418 527-1388
E: jer...@bodycad.com
www.bodycad.com

The contents of this email message and any attachments are intended solely for the addressee(s) and may contain confidential and/or privileged information and may be legally protected from disclosure. If you are not the intended recipient of this message or their agent, or if this message has been addressed to you in error, please immediately alert the sender by reply email and then delete this message and any attachments. If you are not the intended recipient, you are hereby notified that any use, dissemination, copying, or storage of this message or its attachments is strictly prohibited. 

Le contenu de ce message et les pièces jointes sont destinés uniquement pour le(s) destinataire(s) et peuvent contenir des informations confidentielles et / ou privilégiées qui peuvent être protégées légalement contre toute divulgation. Si vous n'êtes pas le destinataire de ce message ou son agent, ou si ce message vous a été adressé par erreur, s’il vous plaît avertir immédiatement l'expéditeur par courriel de réponse, puis supprimer ce message et les pièces jointes. Si vous n'êtes pas le destinataire prévu, vous êtes par la présente informé que toute utilisation, diffusion, copie, ou stockage de ce message ou de ses pièces jointes est strictement interdit.


--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/mIzYWDmMKGM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a82ee9f8-e59e-4e11-9a77-0d57bbb1e352%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Puneet Notani

unread,
Jan 15, 2018, 1:29:34 AM1/15/18
to Jenkins Users
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages