Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.36 KB | None | 0 0
  1. # -*- python -*-
  2. # ex: set syntax=python:
  3. import cgi, datetime, jinja2, buildbot.status.client, re
  4. from os.path import basename, dirname
  5. from sets import Set
  6. from buildbot.changes import filter
  7. from buildbot.changes.gitpoller import GitPoller
  8. from buildbot.config import BuilderConfig
  9. from buildbot.plugins import reporters
  10. from buildbot.plugins import steps
  11. from buildbot.plugins import util
  12. from buildbot.plugins import worker
  13. from buildbot.process.build import Build
  14. from buildbot.process.factory import BuildFactory
  15. from buildbot.process.properties import Property, Interpolate
  16. from buildbot.schedulers import timed
  17. from buildbot.schedulers.basic import SingleBranchScheduler
  18. from buildbot.schedulers.forcesched import ForceScheduler
  19. from buildbot.schedulers.trysched import Try_Userpass
  20. from buildbot.status.builder import Results
  21. from buildbot.www.authz import Authz
  22. from buildbot.steps.source.git import Git
  23. from buildbot.steps.shell import Compile, ShellCommand, SetPropertyFromCommand
  24. from buildbot.steps.transfer import FileUpload
  25.  
  26. # This is the dictionary that the buildmaster pays attention to. We also use
  27. # a shorter alias to save typing.
  28. c = BuildmasterConfig = {}
  29. # The 'services' list used mainly to add reporters.
  30. c['services'] = []
  31. # The 'workers' list defines the slaves available.
  32. c['workers'] = []
  33. # The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
  34. # what steps, and which workers can execute them. Note that any particular build will
  35. # only take place on one worker.
  36. c['builders'] = []
  37. # The schedulers configuration parameter gives a list of Scheduler instances, each of
  38. # which causes builds to be started on a particular set of Builders.
  39. c['schedulers'] = []
  40. # the 'change_source' setting tells the buildmaster how it should find out
  41. # about source code changes.
  42. c['change_source'] = []
  43. # 'protocols' contains information about protocols which master will use for
  44. # communicating with workers. You must define at least 'port' option that workers
  45. # could connect to your master with this protocol.
  46. # 'port' must match the value configured into the workers (with their
  47. # --master option)
  48. c['protocols'] = {'pb': {'port': 9990}}
  49. # the 'title' string will appear at the top of this buildbot
  50. # installation's html.WebStatus home page (linked to the
  51. # 'titleURL') and is embedded in the title of the waterfall HTML page.
  52. c['title'] = "Linux"
  53. c['titleURL'] = "http://www.kernel.org/"
  54. # the 'buildbotURL' string should point to the location where the buildbot's
  55. # internal web server (usually the html.WebStatus page) is visible. This
  56. # typically uses the port number set in the Waterfall 'status' entry, but
  57. # with an externally-visible host name which the buildbot cannot figure out
  58. # without some help.
  59. c['buildbotURL'] = "http://bmaster-1.company.com:8000/"
  60. # 'db' specifies what databases buildbot uses to store its state. You can leave
  61. # this at its default for all but the largest installations.
  62. c['db'] = { "db_url":"sqlite:///state.sqlite" }
  63. # Memory management
  64. # We do have our own script to clean up build logs
  65. c['buildHorizon']   = 0 # Keep the last 0 builds in the disk
  66. c['logHorizon']     = 0 # Keep the 0 most recent build logs in the disk
  67. c['logMaxSize'] = 5 * 1024 * 1024 # 5MB log should be enough to debug the problem
  68. c['logMaxTailSize'] = 32768 # Shouldn't be too high as it is kept in memory
  69. # Caches
  70. c['caches'] = {
  71.     'Changes' : 1000, # For huge merges
  72.     'Builds' : 2, # Just cache the last 2 builds
  73.     'chdicts' : 1000, # == Changes
  74.     'BuildRequests' : 10,
  75.     'SourceStamps' : 10,
  76.     'ssdicts' : 10,
  77.     'objectids' : 10,
  78.     'usdicts' : 10,
  79. }
  80. ######## SMTP credentials ########################
  81. smtp_from = "valid.address@company.com"
  82. smtp_host = "valid.smtp.server@company.com"
  83. smtp_port = 587
  84. smtp_user = "valid.user"
  85. smtp_pass = "valid.pass"
  86. smtp_tls  = True
  87.  
  88. ####### WORKERS
  89. myworkerlist=[]
  90.  
  91. # workers
  92.  
  93. c['workers'].append(
  94.     worker.Worker("bworker-1",
  95.         "valid.master.pass",
  96.         max_builds=1,
  97.         notify_on_missing=["problem.solvers@company.com"],
  98.         missing_timeout=1200
  99.     )
  100. )
  101. myworkerlist.append("bworker-1")
  102.  
  103. ####### BUILDERS ################################
  104. builders_we_care_about = []
  105.  
  106. ####### GIT POLLERS REPOS ########################
  107. gitpollers_repos = {}
  108.  
  109. ####################################################################
  110. #
  111. # BEGIN mainline
  112. #
  113. ####################################################################
  114. mainline_recipients = ["vincent@company.com"]
  115. mainline_factories = {}
  116. mainline_builders = []
  117.  
  118. class MainlineBuildFactory(BuildFactory):
  119.     def __init__(self):
  120.         BuildFactory.__init__(self)
  121.         self.buildClass = Build
  122.  
  123.         # Clean workdir
  124.         self.addStep(
  125.             ShellCommand(
  126.                 command       = Interpolate("rm -Rf %(prop:workdir)s"),
  127.                 name          = "Initial cleanup",
  128.                 timeout       = 3600,
  129.                 maxTime       = 14400,
  130.                 haltOnFailure = True
  131.             )
  132.         )
  133.  
  134. c['builders'].append(
  135.     BuilderConfig(
  136.         name = "Mainline",
  137.         workernames = myworkerlist,
  138.         factory = MainlineBuildFactory()
  139.     )
  140. )
  141.  
  142. mainline_builders.append(name)
  143. builders_we_care_about.append(name)
  144.  
  145. c['services'].append(
  146.     reporters.MailNotifier(
  147.                 fromaddr              = smtp_from,
  148.                 relayhost             = smtp_host,
  149.                 smtpPort              = smtp_port,
  150.                 smtpUser              = smtp_user,
  151.                 smtpPassword          = smtp_pass,
  152.                 useTls                = smtp_tls,
  153.                 extraRecipients       = mainline_recipients,
  154.                 sendToInterestedUsers = False,
  155.                 builders              = mainline_builders,
  156.                 mode                  = "passing",
  157.                 buildSetSummary       = True
  158.     )
  159. )
  160.  
  161. c['services'].append(
  162.     reporters.MailNotifier(
  163.                 fromaddr              = smtp_from,
  164.                 relayhost             = smtp_host,
  165.                 smtpPort              = smtp_port,
  166.                 smtpUser              = smtp_user,
  167.                 smtpPassword          = smtp_pass,
  168.                 useTls                = smtp_tls,
  169.                 extraRecipients       = mainline_recipients,
  170.                 sendToInterestedUsers = False,
  171.                 builders              = mainline_builders,
  172.                 mode                  = "failing"
  173.     )
  174. )
  175. ####################################################################
  176. #
  177. # END mainline
  178. #
  179. ####################################################################
  180.  
  181. ####### GOBAL SCHEDULERS ################################
  182. # Add a ForceScheduler and allow all our builders to use it.
  183. c['schedulers'].append(
  184.         ForceScheduler(
  185.                 name         = "force-scheduler",
  186.                 builderNames = builders_we_care_about
  187.         )
  188. )
  189.  
  190. ####### WEB INTERFACE ######################################
  191. # Custom templates that will be used instead of the default ones
  192. myloaders = [ jinja2.FileSystemLoader(dirname(__file__) + "/templates") ]
  193.  
  194. # Set the web status
  195. c['www'] = {
  196.     'port': 8000,
  197.     'plugins': {
  198.         'waterfall_view': {},
  199.         'console_view': {}
  200.     },
  201. }
  202.  
  203. # Web UI authentication information
  204. authz = Authz(
  205.     allowRules = [
  206.         util.AnyControlEndpointMatcher(role = "admins")
  207.     ],
  208.     roleMatchers = [
  209.         util.RolesFromUsername(roles = ['admins'], usernames = ['admin.username'])
  210.     ]
  211. )
  212. auth = util.UserPasswordAuth({'admin.username':'admin.pass'})
  213. c['www']['auth'] = auth
  214. c['www']['authz'] = authz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement