Integrate Broker for Jenkins (BB-1833)
I have written a broker for Jenkins to allow pushes to bitbucket to trigger builds on Jenkins. It is available here: https://bitbucket.org/mahoney/jenkins-bitbucket-broker
It expects the following fields on the Service:
endpoint the protocol, hostname and port of the Jenkins instance. e.g. https://build.myorg.com:8080
project_name - the Jenkins project to build
token - the secret token to allow builds from scripts. Optional.
module_name - a directory inside the repository. If this is set then the Jenkins build is only triggered if a file within that directory was changed in one of the commits in the changeset. Optional.
I couldn't see any documentation on whether or not brokers are allowed to be stateful, so I've written it as stateless with state kept in a data transfer object. I haven't instantiated that object with get_local because I couldn't see any documentation on how get_local passes arguments to constructors (if it does).
I've assumed there is always a commits entry containing at least one commit in any payload - I hope this assumption is correct. It would be useful if this behaviour were documented.
I've assumed that optional arguments are present in the service dict as empty strings - I hope this assumption is correct.
It should work equally well for the Hudson CI system at the moment, since the Hudson/Jenkins fork is so recent.