Created
June 2, 2014 14:44
-
-
Save frvi/904fed96754c0bfc2af5 to your computer and use it in GitHub Desktop.
Send mail for failing downsteam jobs to source committer, via Jenkins email-ext plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Save in $JENKINS_HOME/email-templates/committers.groovy | |
* Under post build task "Editable Email Notification" | |
* Global Recipient List: "${SCRIPT, script="committers.groovy"}" | |
* | |
* Works with git, see comments for svn usage. | |
*/ | |
def upstreamBuild = null | |
def cause = build.causes.find { | |
if(it instanceof hudson.model.Cause.UpstreamCause) { | |
return true | |
} | |
return false | |
} | |
try { | |
while(cause != null) { | |
upstreamBuild = hudson.model.Hudson.instance.getItem(cause.upstreamProject).getBuildByNumber(cause.upstreamBuild) | |
if(upstreamBuild == null) { | |
break; | |
} | |
cause = upstreamBuild.causes.find { | |
if(it instanceof hudson.model.Cause.UpstreamCause) { | |
return true | |
} | |
return false | |
} | |
} | |
} catch(e) { | |
// do nothing | |
} | |
committers = [] | |
if(upstreamBuild != null && upstreamBuild.changeSet != null) { | |
upstreamBuild.changeSet.each() { cs -> | |
email = hudson.model.Hudson.instance.getUser(cs.authorEmail) // GitChangeSet from git-plugin | |
//if(cs.user != null) { // If using svn | |
if(email != null) { | |
//committers.add(user.id) // If using svn | |
committers.add(email) | |
} | |
} | |
} | |
committers.unique().join(',') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment