Child pages
  • Display mail notifications recipients
Skip to end of metadata
Go to start of metadata

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.

Update (from http://scriptlerweb.appspot.com/script/show/46001): Now with ExternalJobs - tested with Jenkins 1.436

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 ExternalJob)) {
 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);
 }
 }
 } else {
 println("External Jobs cannot have MailNotificationsRecipients")
 }
 println("\n=======\n");
}

  • No labels