Can Buildbot WebStatus be customized to return content type other than text/html

367 Views Asked by At

As a final step in my builds I have FileUpload step to upload results to the master and I'm using BuildBot WebStatus component to serve build results (.apk files in this case). Unfortunately WebStatus always return text/html content type for all files. Is it possible to configure WebStatus so, that it would reconize file extension and return content type based on that information.

4

There are 4 best solutions below

0
On BEST ANSWER

buildbot uses twisted.web.static.File to serve content from the public_html directory. Looking at the source, this uses /etc/mime.types by default, to get mime type information. There is no direct way to override this.

0
On

Of course it's possible - Buildbot is completely written in Python, so all you have to do is either edit the source or subclass WebStatus in your master config file to override the appropriate methods.

Take a look at the source code at https://github.com/buildbot/buildbot if you're curious. Buildbot uses the Twisted asynchronous programming library.

However, it's not a built-in feature of the WebStatus, so adding it would involve writing Python code, not just a config parameter change.

0
On

As other answers have indicated, there's no direct configuration that solves the problem. However you can use a simple subclass to change the default content type, which will at least make it default to text/plain instead of text/html for extensions it doesn't understand:

class WebStatusWithTextDefault(html.WebStatus):
    def setupSite(self):
        result = html.WebStatus.setupSite(self)
        self.site.resource.defaultType = "text/plain"
        return result

Replace the reference to html.WebStatus in your master.cfg with this class and you should be good to go.

0
On

As others pointed out, buildbot uses uses twisted.web.static.File which builds it's list from /etc/mime.types. You can simply extend that list from your master configuration, as it is just a static dict.

The following 2 lines in your master.cfg would do exactly that: define the apk extension as android packages. You can add as many as you want, or simply change existing ones.

  import twisted.web.static
  twisted.web.static.File.contentTypes['.apk'] = 'application/vnd.android.package-archive'