diff --git a/README.md b/README.md index fbcb33e4..361b64aa 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ Then add **hubot-pager-me** to your `external-scripts.json`: * HUBOT_PAGERDUTY_API_KEY - Get one from https://.pagerduty.com/api_keys * HUBOT_PAGERDUTY_SERVICE_API_KEY - Service API Key from a 'General API Service'. This should be assigned to a dummy escalation policy that doesn't actually notify, as hubot will trigger on this before reassigning it * HUBOT_PAGERDUTY_SERVICES - (optional) Provide a comma separated list of service identifiers (e.g. `PFGPBFY`) to restrict queries to only those services. +* HUBOT_PAGERDUTY_SCHEDULES_BLACKLIST - (optional) Provide a comman seperated blacklist of schedule names to filter out when querying for 'whos on call' + (e.g. `Backup,Secondary` will remove all schedules with either the words 'Backup' or 'Secondary' in the schedule name) ### Webhook diff --git a/src/scripts/pagerduty.coffee b/src/scripts/pagerduty.coffee index 9065a3ff..30eb673a 100644 --- a/src/scripts/pagerduty.coffee +++ b/src/scripts/pagerduty.coffee @@ -602,6 +602,10 @@ module.exports = (robot) -> robot.emit 'error', err, msg return if schedules.length > 0 + if process.env.HUBOT_PAGERDUTY_SCHEDULES_BLACKLIST + schedules_blacklist_regex = new RegExp("(" + process.env.HUBOT_PAGERDUTY_SCHEDULES_BLACKLIST.replace(/,/g, '|') + ")") + schedules = schedules.filter (schedule) -> !schedule.name.match(schedules_blacklist_regex) + async.map schedules, renderSchedule, (err) -> if err? robot.emit 'error', err, msg