4

I'm trying customizing the webstatus templates for my buildbot 0.8.8 installation According to the documentation:

Buildbot uses a templating system for the web interface. The source of these templates can be found in the status/web/templates/ directory in buildbot's library area. You can override these templates by creating alternate versions in a templates/ directory within the buildmaster's base directory.

Here what I did:

  • copied all html templates from my buildbot installation folder (/usr/lib64/.../status/web/templates) into the templates folder I found inside my buildmaster installation root folder (the templates was already there, and it contains a README file that seems to confirm what the documentation states)
  • modified the root.html templates

Unfortunately I cannot see any changes in the webstatus page.

Another test I did is to directly change the original template file in the buildbot installation path. The changes are now displayed. It seems like the buildmaster is not "seeing" the new template in the local configuration path. I checked the file/dir permissions and I cannot spot any issue on that side.

Tried cleaning up the browser cache without luck as well. Have I done something wrong?

sergico
  • 2,595
  • 2
  • 29
  • 40
  • I have overwritten the root.html and placed it in the {master_dir}/templates. It works for me ! But I copy my modified root.html file during the buildmaster configuration i.e. when I start the buildmaster. – sk11 Jul 02 '14 at 07:15
  • 1
    @sk11 someone on the buildbot mailing list pointed out the need to restart the master after putting a new template file in {master_dir}/templates, so that the buildmaster is aware of the new files. Unfortunately that doesn't worked for me. I can see the modifications only if I modify the template files in the system wide installation. – sergico Jul 02 '14 at 08:37
  • Why don't you restart the master and slave after you make changes in your templates directory? – 277roshan Aug 06 '15 at 21:36

1 Answers1

2

As per source code, templates are retrieved from the WebStatus objects, i.e. builder.py:573 ([1]) :

template = req.site.buildbot_service.templates.get_template("builders.html")

This property is created in baseweb.py:465 ([2]) :

self.templates = createJinjaEnv(revlink, self.changecommentlink,
                                    self.repositories, self.projects, self.jinja_loaders)

The template lookup algorithm can be found in createJinjaEnv function, around base.py:506 ([3]) :

all_loaders = [jinja2.FileSystemLoader(os.path.join(os.getcwd(), 'templates'))]
if jinja_loaders:
    all_loaders.extend(jinja_loaders)
all_loaders.append(jinja2.PackageLoader('buildbot.status.web', 'templates'))
loader = jinja2.ChoiceLoader(all_loaders)

As per documentation [4], jinja will return the first existing file in specified list, so while trying to load your template, Jinja will lookup sequentially in :

  • cwd
  • jinja_loaders property, that can be defined in WebStatus constructor by jinja_loaders param in your master.cfg
  • files from python package

IMO the easiest option is the second.

Hope it helps

[1]https://github.com/buildbot/buildbot/blob/2ab0e16ed0c46249f1d33308fd6878a1fc953f6e/master/buildbot/status/web/builder.py#L573 [2]https://github.com/buildbot/buildbot/blob/2ab0e16ed0c46249f1d33308fd6878a1fc953f6e/master/buildbot/status/web/baseweb.py#L465 [3]https://github.com/buildbot/buildbot/blob/2ab0e16ed0c46249f1d33308fd6878a1fc953f6e/master/buildbot/status/web/base.py#L506 [4]http://jinja.pocoo.org/docs/dev/api/#jinja2.ChoiceLoader

cthepenier
  • 305
  • 3
  • 9