Friday, September 2, 2011

Jenkins script for mass-update of email recipients


This is a handy Jenkins Groovy script that can be used to update all the mail recipients for your Maven projects.  If you have a ton of projects, this can be way-faster than changing them each by hand.  I'm putting this here for the Googling and my own notes.

import hudson.plugins.emailext.*
import hudson.model.*
import hudson.maven.*
import hudson.maven.reporters.*
import hudson.tasks.*


// For each project
for(item in Hudson.instance.items) {
  println("JOB : "+item.name);
  for( reporter in item.reporters) {
    if(reporter instanceof MavenMailer) {
      reporter.recipients = "new@email"
    }
  }
}