Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Jenkinsのスクリプトコンソールで、ジョブに一括してSlack通知を設定するスクリプト
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