The template files use the syntax of the SimpleTemplateEngine [1] from
Groovy. The email-ext.groovy is the default file that sets up the
SimpleTemplateEngine. I've been meaning to change this so that the script
is not needed, it just sets up some bindings for the template and I don't
believe anyone is changing that file. In the Groovy templates, you can use
code blocks to do operations and use the full Groovy language to do things
intermixed with the output generation. Think along the lines of PHP or JSP
where you have code embedded along with the HTML/rendering. The default
templates have some try/catch blocks and some if/else type blocks, you
could also use the built-in regex support in Groovy to do what you want
with the regex.

<%
def yourStuff = yourString =~ /someregex/
%>

blah blah ${yourStuff}


1 - http://groovy.codehaus.org/Groovy+Templates


On Thu, Apr 4, 2013 at 10:45 AM, Kamal Ahmed <kamal2222ah...@yahoo.com>wrote:

> My only excuse is mostly my lack of groovy knowledge, and how it would
> work.
>
> 1. I see the .groovy files and .template files, which one's should i use :
>
>   ${SCRIPT,template="groovy-html.template"}
>
> or:
>
>   ${SCRIPT,groovy="email-ext.groovy"}
>
>
> and if we look at jelly vs Groovy:
>
> Jelly ( html.jelly )
>
> <!-- GENERAL INFO -->
>
> <TABLE>
>   <TR><TD align="right">
>     <j:choose>
>       <j:when test="${build.result=='SUCCESS'}">
>         <IMG SRC="${rooturl}static/e59dfe28/images/32x32/blue.gif" />
>       </j:when>
>           <j:when test="${build.result=='FAILURE'}">
>         <IMG SRC="${rooturl}static/e59dfe28/images/32x32/red.gif" />
>       </j:when>
>       <j:otherwise>
>         <IMG SRC="${rooturl}static/e59dfe28/images/32x32/yellow.gif" />
>       </j:otherwise>
>     </j:choose>
>   </TD><TD valign="center"><B style="font-size: 200%;">BUILD
> ${build.result}</B></TD></TR>
>   <TR><TD>Build URL</TD><TD><A
> href="${rooturl}${build.url}">${rooturl}${build.url}</A></TD></TR>
>   <TR><TD>Project:</TD><TD>${project.name}</TD></TR>
>   <TR><TD>Date of build:</TD><TD>${it.timestampString}</TD></TR>
>   <TR><TD>Build duration:</TD><TD>${build.durationString}</TD></TR>
> </TABLE>
> <BR/>
>
> in Groovy : (groovy-html.template)
>
> <TABLE>
>   <TR><TD align="right"><IMG
> SRC="${rooturl}static/e59dfe28/images/32x32/<%= build.result.toString() ==
> 'SUCCESS' ? "blue.gif" : build.result.toString() == 'FAILURE' ? 'red.gif' :
> 'yellow.gif' %>" />
>   </TD><TD valign="center"><B style="font-size: 200%;">BUILD
> ${build.result}</B></TD></TR>
>   <TR><TD>Build URL</TD><TD><A
> href="${rooturl}${build.url}">${rooturl}${build.url}</A></TD></TR>
>   <TR><TD>Project:</TD><TD>${project.name}</TD></TR>
>   <TR><TD>Date of build:</TD><TD>${it.timestampString}</TD></TR>
>   <TR><TD>Build duration:</TD><TD>${build.durationString}</TD></TR>
> </TABLE>
>
>
> Am i missing something, and what do i gain by switching to Groovy, unless
> the sample scripts are bad examples. I was sort of Expecting the Groovy to
> be more like we Code in Java.
>
> Thanks,
> -Kamal.
>
>   ------------------------------
> *From:* Slide <slide.o....@gmail.com>
> *To:* "jenkinsci-users@googlegroups.com" <jenkinsci-users@googlegroups.com>
>
> *Sent:* Thursday, April 4, 2013 1:09 PM
> *Subject:* Re: email-ext reporting Branch name
>
> Well, is there a reason you aren't doing this in Groovy? It would be
> orders of magnitude easier than trying to do it in Jelly.
>
>
> On Thu, Apr 4, 2013 at 9:39 AM, Kamal Ahmed <kamal2222ah...@yahoo.com>wrote:
>
> Hi,
>
> I  want to be able to use jelly script ( Apologize for not doing this in
> Groovy ) to display the branch name on which the changeset was submitted in
> subversion.
>
> Like , here is a snippet of my custom.jelly
>
> The p.path string is :
> /perlapp/trunk/cgi-bin/developer/smeview/reviewfiles/demo/cui_sample.csv
>
> so, i want to extract "perlapp" and "trunk" and display them in the email
> header.
>
>
>
>   <TD>Build duration:</TD>
>         <TD>${build.durationString}</TD>
>       </TR>
>       <TR>
>         <TD>Branch:</TD>
>         <TD>I want to do a regex here on ${p.path} to extract the first
> and second string</TD>
>       </TR>
>     </TABLE>
>     <BR />
>     <!-- CHANGE SET -->
>     <j:set var="changeSet" value="${build.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<http://p.edittype.name/>
> }</TD>
>               <TD>${p.path}</TD>
>  --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>
>
> --
> Website: http://earl-of-code.com
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>    --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Website: http://earl-of-code.com

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to