Re: email-ext - request for another jelly script example

2012-03-27 Thread dpreilan
Create your groovy script and place in under your $JENKINS_HOME/email-
templates. Create the email-templates directory if needed.
Say you call it foo.template.

In your jenkins job(s), configure your Editable Email Notification
Content area, like:

${SCRIPT,template=foo.template}

Make sure you set 'Content Type' correctly (hml or text) based on what
output you are giving.
Also, if you have configured seperate triggers under advanced for
failured, fixed, ..., you might need to added the content there as
well which is what I do.

Doug

On Mar 24, 6:08 am, Chris Withers ch...@simplistix.co.uk wrote:
 On 24/03/2012 00:48, Slide wrote:





  I use something like this in my groovy template

  // the goal is to find the top level job which should contain the changelist
  def upstreamBuild = null
  def cause = build.causes.find {
       if(it instanceof hudson.model.Cause.UpstreamCause) {
           return true
       }
       return false
  }

  while(cause != null) {
       upstreamBuild =
  hudson.model.Hudson.instance.getItem(cause.upstreamProject).getBuildByNumbe­r(cause.upstreamBuild)
       cause = upstreamBuild.causes.find {
           return (it instanceof hudson.model.Cause.UpstreamCause);
       }
  }

  Then I check if upstreamBuild is null or not, and if its not, I have
  access to its information like this:

  def changeSet = upstreamBuild.changeSet

  And you can get the info you are looking for from there.

 Wow, cool, I'm afraid I'm a bit clueless though...

 Where do I put the code you've written above? File on disk or box in UI?
 (it either case, where and called what?)

 Once I've done that, how do I wire it into the email-ext template?

 cheers,

 Chris

 --
 Simplistix - Content Management, Batch Processing  Python Consulting
             -http://www.simplistix.co.uk- Hide quoted text -

 - Show quoted text -


Re: email-ext - request for another jelly script example

2012-03-24 Thread Chris Withers

On 24/03/2012 00:48, Slide wrote:

I use something like this in my groovy template

// the goal is to find the top level job which should contain the changelist
def upstreamBuild = null
def cause = build.causes.find {
 if(it instanceof hudson.model.Cause.UpstreamCause) {
 return true
 }
 return false
}

while(cause != null) {
 upstreamBuild =
hudson.model.Hudson.instance.getItem(cause.upstreamProject).getBuildByNumber(cause.upstreamBuild)
 cause = upstreamBuild.causes.find {
 return (it instanceof hudson.model.Cause.UpstreamCause);
 }
}

Then I check if upstreamBuild is null or not, and if its not, I have
access to its information like this:

def changeSet = upstreamBuild.changeSet

And you can get the info you are looking for from there.


Wow, cool, I'm afraid I'm a bit clueless though...

Where do I put the code you've written above? File on disk or box in UI?
(it either case, where and called what?)

Once I've done that, how do I wire it into the email-ext template?

cheers,

Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
   - http://www.simplistix.co.uk


Re: email-ext - request for another jelly script example

2012-03-23 Thread Slide
I use something like this in my groovy template

// the goal is to find the top level job which should contain the changelist
def upstreamBuild = null
def cause = build.causes.find {
if(it instanceof hudson.model.Cause.UpstreamCause) {
return true
}
return false
}

while(cause != null) {
upstreamBuild =
hudson.model.Hudson.instance.getItem(cause.upstreamProject).getBuildByNumber(cause.upstreamBuild)
cause = upstreamBuild.causes.find {
return (it instanceof hudson.model.Cause.UpstreamCause);
}
}

Then I check if upstreamBuild is null or not, and if its not, I have access
to its information like this:

def changeSet = upstreamBuild.changeSet

And you can get the info you are looking for from there.

slide


On Fri, Mar 23, 2012 at 3:35 AM, Chris Withers ch...@simplistix.co.ukwrote:

 On 19/03/2012 15:26, Slide wrote:

 This is awesome. Thanks for sharing! I've heard of several people who
 would like to do something like this. I'll try and add it to the wiki
 for email-ext.


 Sorry for topic hijacking, but I tried asking this before and got no
 response, yet this topic seems similar...

 So, I have a job (A) that uses artifacts from another job (B) and is also
 triggered by that job. That other job does the SCM polling, so when tests
 in Job A fail, them changelog is blank, just says triggered by build #x of
 Job A.

 Does anyone have an email-ext example of how to get the changelog from Job
 A into the email-ext mail sent if Job B fails?

 cheers,

 Chris

 --
 Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk




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