def genSchedulerTrigger(trigger_name, repo, refs, path_regexps, builds):
  """Generate the luci scheduler job for a given build config.

  Args:
    trigger_name: Name of the trigger as a string.
    repo: Gitiles URL git git repository.
    refs: Iterable of git refs to check. May use regular expressions.
    path_regexps: Iterable of path regular expressions of files to trigger on
        or falsy to trigger on everything.
    builds: Iterable of build config names to trigger.

  Returns:
    Multiline string to include in the luci scheduler configuration.
  """
  template = """
trigger {
  id: "%(trigger_name)s"
  acl_sets: "default"
  schedule: "with 5m interval"
  gitiles: {
    repo: "%(repo)s"
%(refs)s%(path_regexps)s
  }
%(triggers)s
}
"""
  if path_regexps:
    path_regexps = '\n' + '\n'.join('    path_regexps: "%s"' %
                                    r for r in path_regexps)
  else:
    path_regexps = ''
  return template % {
      'trigger_name': trigger_name,
      'repo': repo,
      'refs': '\n'.join('    refs: "%s"' % r for r in refs),
      'path_regexps': path_regexps,
      'triggers': '\n'.join('  triggers: "%s"' % b for b in builds),
  }