Caution

Buildbot no longer supports Python 2.7 on the Buildbot master.

2.5.14.6. GerritStatusPush

GerritStatusPush sends review of the Change back to the Gerrit server, optionally also sending a message when a build is started. GerritStatusPush can send a separate review for each build that completes, or a single review summarizing the results for all of the builds.

class buildbot.reporters.status_gerrit.GerritStatusPush(server, username, reviewCB, startCB, port, reviewArg, startArg, summaryCB, summaryArg, identity_file, builders, notify...)
Parameters
  • server (string) – Gerrit SSH server’s address to use for push event notifications.

  • username (string) – Gerrit SSH server’s username.

  • identity_file – (optional) Gerrit SSH identity file.

  • port (int) – (optional) Gerrit SSH server’s port (default: 29418)

  • reviewCB – (optional) Called each time a build finishes. Build properties are available. Can be a deferred.

  • reviewArg

    (optional) Argument passed to the review callback.

    :: If reviewCB callback is specified, it must return a message and optionally labels. If no message is specified, nothing will be sent to Gerrit. It should return a dictionary:

    {'message': message,
     'labels': {label-name: label-score,
                ...}
    }
    

    For example:

    def gerritReviewCB(builderName, build, result, master, arg):
        if result == util.RETRY:
            return dict()
    
        message =  "Buildbot finished compiling your patchset\n"
        message += "on configuration: %s\n" % builderName
        message += "The result is: %s\n" % util.Results[result].upper()
    
        if arg:
            message += "\nFor more details visit:\n"
            message += build['url'] + "\n"
    
        if result == util.SUCCESS:
            verified = 1
        else:
            verified = -1
    
        return dict(message=message, labels={'Verified': verified})
    

    Which require an extra import in the config:

    from buildbot.plugins import util
    

  • startCB – (optional) Called each time a build is started. Build properties are available. Can be a deferred.

  • startArg

    (optional) Argument passed to the start callback.

    If startCB is specified, it must return a message and optionally labels. If no message is specified, nothing will be sent to Gerrit. It should return a dictionary:

    {'message': message,
     'labels': {label-name: label-score,
                ...}
    }
    

    For example:

    def gerritStartCB(builderName, build, arg):
        message = "Buildbot started compiling your patchset\n"
        message += "on configuration: %s\n" % builderName
        message += "See your build here: %s" % build['url']
    
        return dict(message=message)
    

  • summaryCB – (optional) Called each time a buildset finishes. Each build in the buildset has properties available. Can be a deferred.

  • summaryArg

    (optional) Argument passed to the summary callback.

    If summaryCB callback is specified, it must return a message and optionally labels. If no message is specified, nothing will be sent to Gerrit. The message and labels should be a summary of all the builds within the buildset. It should return a dictionary:

    {'message': message,
     'labels': {label-name: label-score,
                ...}
    }
    

    For example:

    def gerritSummaryCB(buildInfoList, results, status, arg):
        success = False
        failure = False
    
        msgs = []
    
        for buildInfo in buildInfoList:
            msg = "Builder %(name)s %(resultText)s (%(text)s)" % buildInfo
            link = buildInfo.get('url', None)
            if link:
                msg += " - " + link
            else:
                msg += "."
    
            msgs.append(msg)
    
            if buildInfo['result'] == util.SUCCESS:
                success = True
            else:
                failure = True
    
        if success and not failure:
            verified = 1
        else:
            verified = -1
    
        return dict(message='\n\n'.join(msgs),
                    labels={
                        'Verified': verified
                    })
    

  • builders – (optional) List of builders to send results for. This method allows to filter results for a specific set of builder. By default, or if builders is None, then no filtering is performed.

  • notify – (optional) Control who gets notified by Gerrit once the status is posted. The possible values for notify can be found in your version of the Gerrit documentation for the gerrit review command.

  • wantSteps – (optional, defaults to False) Extends the given build object with information about steps of the build. Use it only when necessary as this increases the overhead in term of CPU and memory on the master.

  • wantLogs – (optional, default to False) Extends the steps of the given build object with the full logs of the build. This requires wantSteps to be True. Use it only when mandatory as this increases the overhead in term of CPU and memory on the master greatly.

Note

By default, a single summary review is sent; that is, a default summaryCB is provided, but no reviewCB or startCB.

Note

If reviewCB or summaryCB do not return any labels, only a message will be pushed to the Gerrit server.

See also

master/docs/examples/git_gerrit.cfg and master/docs/examples/repo_gerrit.cfg in the Buildbot distribution provide a full example setup of Git+Gerrit or Repo+Gerrit of GerritStatusPush.