You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
3.8KB

  1. {{ansible_managed|comment}}
  2. from buildbot.plugins import *
  3. import glob, json
  4. c = BuildmasterConfig = {}
  5. c['workers'] = []
  6. c['change_source'] = []
  7. c['schedulers'] = []
  8. c['builders'] = []
  9. c['services'] = []
  10. c['protocols'] = {
  11. 'pb': {
  12. 'port': "tcp:9989:interface=127.0.0.1"
  13. }
  14. }
  15. c['title'] = "{{buildbot_title}}"
  16. c['titleURL'] = "{{buildbot_title_url}}"
  17. c['buildbotURL'] = "{{ buildbot_base_url }}"
  18. c['www'] = dict(
  19. port="unix:address=/run/buildbot/{{buildbot_server_name}}.www.sock",
  20. plugins = dict(
  21. waterfall_view={},
  22. console_view={},
  23. grid_view={},
  24. badges={"left_pad": 0, "right_pad": 0, "border_radius": 3, "style": "badgeio"},
  25. ),
  26. change_hook_dialects={
  27. {% if buildbot_github_change_hook %}
  28. 'github': {},
  29. {% endif %}
  30. {% if buildbot_gitea_change_hook %}
  31. 'gitea': {
  32. 'secret': '{{buildbot_gitea_webhook_secret}}',
  33. 'onlyIncludePushCommit': False,
  34. },
  35. {% endif %}
  36. },
  37. )
  38. c['db'] = {
  39. 'db_url' : "{{buildbot_database_url}}",
  40. }
  41. # Local Worker
  42. {% if buildbot_local_worker %}
  43. c['workers'].append(worker.LocalWorker("local-worker"))
  44. {% endif %}
  45. # External Workers Config
  46. workers_config_file_paths = glob.glob("*.workers.json")
  47. for workers_config_file_path in workers_config_file_paths:
  48. with open(workers_config_file_path) as workers_config_file:
  49. workers_config = json.load(workers_config_file)
  50. for (worker_name, worker_config) in workers_config.items():
  51. c['workers'].append(worker.Worker(worker_name, worker_config['password']))
  52. # Hello World Example
  53. {% if buildbot_hello_world_example %}
  54. factory = util.BuildFactory()
  55. factory.addStep(steps.Git(repourl='git://github.com/buildbot/hello-world.git', mode='incremental'))
  56. factory.addStep(steps.ShellCommand(command=["trial", "hello"], env={"PYTHONPATH": "."}))
  57. c['builders'].append(
  58. util.BuilderConfig(
  59. name="hello-world",
  60. workernames=["local-worker"],
  61. factory=factory
  62. )
  63. )
  64. c['schedulers'].append(schedulers.ForceScheduler(
  65. name="force-hello-world",
  66. builderNames=["hello-world"],
  67. ))
  68. {% endif %}
  69. # External Builders Config
  70. builders_config_file_paths = glob.glob("*.builders.json")
  71. for builders_config_file_path in builders_config_file_paths:
  72. with open(builders_config_file_path) as builders_config_file:
  73. builders_config = json.load(builders_config_file)
  74. for (builder_name, builder_config) in builders_config.items():
  75. factory = util.BuildFactory()
  76. c['builders'].append(
  77. util.BuilderConfig(
  78. name=builder_name,
  79. workernames=builder_config['worker_names'],
  80. factory=factory
  81. )
  82. )
  83. repo = builder_config['repo']
  84. if repo['type'] == 'github':
  85. factory.addStep(steps.GitHub(
  86. repourl=repo['url'],
  87. mode='incremental',
  88. branch=repo["branch"],
  89. workdir=repo['workdir'],
  90. progress=True,
  91. submodules=True,
  92. ))
  93. elif repo['type'] == 'gitea':
  94. factory.addStep(steps.Gitea(
  95. repourl=repo['url'],
  96. mode='incremental',
  97. branch=repo["branch"],
  98. workdir=repo['workdir'],
  99. progress=True,
  100. submodules=True,
  101. ))
  102. for cmd in builder_config['shell_commands']:
  103. factory.addStep(steps.ShellCommand(
  104. name=cmd['name'],
  105. command=cmd['command'],
  106. workdir=cmd['workdir'],
  107. ))
  108. c['schedulers'].append(schedulers.SingleBranchScheduler(
  109. name=builder_name,
  110. change_filter=util.ChangeFilter(branch=builder_config['repo']['branch']),
  111. treeStableTimer=5,
  112. builderNames=[builder_name],
  113. ))
  114. if ('force_scheduler' in builder_config) and (builder_config['force_scheduler'] == True):
  115. c['schedulers'].append(schedulers.ForceScheduler(
  116. name="build-%s" % builder_name,
  117. builderNames=[builder_name],
  118. ))