Skip to content

Instantly share code, notes, and snippets.

@doismellburning
Created November 12, 2012 19:02
Show Gist options
  • Save doismellburning/4061188 to your computer and use it in GitHub Desktop.
Save doismellburning/4061188 to your computer and use it in GitHub Desktop.
import hudson.model.*
import hudson.maven.*
import hudson.tasks.*
import com.tikal.hudson.plugins.notification.HudsonNotificationProperty
import com.tikal.hudson.plugins.notification.Endpoint
import com.tikal.hudson.plugins.notification.Protocol
String URL = "http://example.com/bot/jenkins"
for(item in Hudson.instance.items) {
println("job: $item.name")
hasNotification = false
item.properties.each{
if (it.value instanceof com.tikal.hudson.plugins.notification.HudsonNotificationProperty) {
hasNotification = true
println("$item.name has notifier!")
}
}
if (!hasNotification) {
ArrayList<Endpoint> es = new ArrayList<Endpoint>()
es.add(new Endpoint(Protocol.HTTP, URL))
JobProperty p = new HudsonNotificationProperty(es)
assert(p != null)
item.addProperty(p)
println("Added notifier to $item.name")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment