Last active
August 29, 2015 14:18
-
-
Save yuroyoro/337b72638578bafd50e5 to your computer and use it in GitHub Desktop.
Jenkinsのスクリプトコンソールで、ジョブに一括してSlack通知を設定するスクリプト
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
jobs = jenkins.model.Jenkins.instance.items | |
jobs.each {job -> | |
job.removeProperty(jenkins.plugins.slack.SlackNotifier.SlackJobProperty) | |
jp = new jenkins.plugins.slack.SlackNotifier.SlackJobProperty( | |
null, // String teamDomain, | |
null, // String token, | |
"#channel_to_notified", // String room, | |
false, // boolean startNotification, | |
true, // boolean notifyAborted, | |
true, // boolean notifyFailure, | |
false, // boolean notifyNotBuilt, | |
false, // boolean notifySuccess, | |
false, // boolean notifyUnstable, | |
true, // boolean notifyBackToNormal, | |
true, // boolean notifyRepeatedFailure, | |
false, // boolean includeTestSummary, | |
true, // boolean showCommitList | |
) | |
job.addProperty(jp) | |
list = job.getPublishersList() | |
publisher = list.get(jenkins.plugins.slack.SlackNotifier.class) | |
if( publisher) { | |
list.remove(publisher) | |
} | |
list.remove(jenkins.plugins.slack.SlackNotifier.class) | |
publisher = new jenkins.plugins.slack.SlackNotifier( | |
"your slack domain", // teamDomain, | |
"your slack token", // token, | |
"", // room, | |
"/", // buildServerUrl, | |
null // sendAs | |
); | |
job.getPublishersList().add(publisher) | |
job.save() | |
println "updated ${job.getName()} " | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment