Next: , Previous: GitPoller, Up: Change Sources


4.6.10 GerritChangeSource

The GerritChangeSource class connects to a Gerrit server by its SSH interface and uses its event source mechanism, gerrit stream-events.

This class adds a change to the buildbot system for each of the following events:

patchset-created
A change is proposed for review. Automatic checks like checkpatch.pl can be automatically triggered. Beware of what kind of automatic task you trigger. At this point, no trusted human has reviewed the code, and a patch could be specially crafted by an attacker to compromise your buildslaves.
ref-updated
A change has been merged into the repository. Typically, this kind of event can lead to a complete rebuild of the project, and upload binaries to an incremental build results server.

This class will populate the property list of the triggered build with the info received from Gerrit server in JSON format.

In case of “patchset-created” event, these properties will be:

event.change.branch
Branch of the Change
event.change.id
Change's ID in the Gerrit system (the ChangeId: in commit comments)
event.change.number
Change's number in Gerrit system
event.change.owner.email
Change's owner email (owner is first uploader)
event.change.owner.name
Change's owner name
event.change.project
Project of the Change
event.change.subject
Change's subject
event.change.url
URL of the Change in the Gerrit's web interface
event.patchSet.number
Patchset's version number
event.patchSet.ref
Patchset's Gerrit "virtual branch"
event.patchSet.revision
Patchset's Git commit ID
event.patchSet.uploader.email
Patchset uploader's email (owner is first uploader)
event.patchSet.uploader.name
Patchset uploader's name (owner is first uploader)
event.type
Event type (“patchset-created”)
event.uploader.email
Patchset uploader's email
event.uploader.name
Patchset uploader's name

In case of “ref-updated” event, these properties will be:

event.refUpdate.newRev
New Git commit ID (after merger)
event.refUpdate.oldRev
Previous Git commit ID (before merger)
event.refUpdate.project
Project that was updated
event.refUpdate.refName
Branch that was updated
event.submitter.email
Submitter's email (merger responsible)
event.submitter.name
Submitter's name (merger responsible)
event.type
Event type (“ref-updated”)
event.submitter.email
Submitter's email (merger responsible)
event.submitter.name
Submitter's name (merger responsible)

Example

     from buildbot.changes.gerritchangesource import GerritChangeSource
     c['change_source'] = GerritChangeSource(gerrit_server, gerrit_user)

see master/docs/examples/repo_gerrit.cfg in the Buildbot distribution for an example setup of GerritChangeSource.