0

I am interested in gathering every change that the Buildbot receive.

Ideally I need what is displayed in the web page for a commit:

Category
Changed by
Changed at
Repository
Branch  
Revision
Comments
Changed files

How do I access these field from either the cfg file or a custom class? I would like to have them all saved either in a text file or in a dictionary, sequentially; every time that the Buildbot receive a change that trigger a build; but I have no idea how to access them.

1 Answers1

0

Have a look at Source Stamp Properties There in changes you have access to these attributes.

So in a custom buildStep you could do something like:

def start(self):
    branch = self.getProperty('branch')
    revision = self.getProperty('revision')
    repository = self.getProperty('repository')
    changes = self.getProperty("changes") or [] # returns None if there are no changes
    for ch in changes:
        changed_by = ch.who
        changed_at = ch.when
        comments = ch.comments
        changed_files = ch.files

    #save to file in master
    #call super start
hithwen
  • 2,154
  • 28
  • 46
  • Thanks! Is there a list of the property supported by getProperty()? I saw your link and was wondering if there is also access to the file modified and other build related data. Also if I trigger my custom build step from another class; when I call for example 'revision'; do I get the revision of the calling builder? –  May 12 '14 at 19:56
  • 1
    The properties are accesible for any buildStep and do not tend to change across the build (ie: the branch, revision and repository is the same in every step), complete list of properties is [here](http://docs.buildbot.net/latest/manual/cfg-properties.html#properties). You can set your own properties with self.setProperty(name, value, setter, set_on_runtime). In the slave (start method) you can access all the files (modified or not) in your workspace/build directory. – hithwen May 13 '14 at 07:01
  • Thanks hitwen. I gave it a try, but I am getting errors. When I restart, and the cfg file check my custom class, it raise errors saying that self is not declared. I tried a simple subclass from ShellCommand, and put the code that you wrote in the summary function, so I can populate the logs and grab them from the master in the cfg file, to either go out via mail or on the web status page. Is there any caveat to use the code that you pasted? It must be in the start? Thanks!! –  May 16 '14 at 21:08
  • 1
    Hi the code I pasted should be a class method (for example a subclass of ShellCommand as you said) It was missing self in method declaration. I edited the answer. You can read more abot rewriting start [here](http://docs.buildbot.net/latest/manual/new-style-steps.html#rewriting-start) – hithwen May 17 '14 at 08:06
  • Thanks! BTW is this already in the current build(0.8.8)? I see that these are the steps in the latest docs, which often are referring to unreleased function. –  May 20 '14 at 04:27
  • 1
    You can check 0.8.8 documentation [here](http://docs.buildbot.net/0.8.8/manual/cfg-properties.html) I personally use branch property a lot, as for changes only in [fileIsImportant function](http://docs.buildbot.net/0.8.8/manual/cfg-schedulers.html) which receives the changes object does not need to call the property – hithwen May 20 '14 at 08:42