Created
November 12, 2012 19:02
-
-
Save doismellburning/4061188 to your computer and use it in GitHub Desktop.
This file contains 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
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