Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuroyoro/337b72638578bafd50e5 to your computer and use it in GitHub Desktop.
Save yuroyoro/337b72638578bafd50e5 to your computer and use it in GitHub Desktop.
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