Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Display mail notifications recipients

This script displays for all jobs the list of mail recipients used for notifications. It supports, Standard mail notifications, Maven Jobs Notifications and Mail-Ext plugin. It was tested on Freestyle and Maven projects with Hudson 1.346.

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);
  // Find current recipients defined in project
  if(item instanceof MavenModuleSet) {
    println(">MAVEN MODULE SET");
    // Search for Maven Mailer Reporter
    println(">>Reporters");    
    for(reporter in item.reporters) {
      if(reporter instanceof MavenMailer) {
        println(">>> reporter : "+reporter+" : "+reporter.recipients);
      }
    }
  } else
  if(item instanceof FreeStyleProject) {
    println(">FREESTYLE PROJECT");
  }
  println(">>Publishers");    
  for(publisher in item.publishersList) {
    // Search for default Mailer Publisher (doesn't exist for Maven projects)
    if(publisher instanceof Mailer) {
      println(">>> publisher : "+publisher+" : "+publisher.recipients);
    } else
    // Or for Extended Email Publisher
    if(publisher instanceof ExtendedEmailPublisher) {
      println(">>> publisher : "+publisher+" : "+publisher.recipientList);
    }
  }   
  println("\n=======\n");
}

Back to the top