This pertains to:
Buildbot version: 0.8.8
Twisted version: 13.2.0
I had some serious issues to get it working with a simple hg repo, while the same project worked fine with git and the appropriate functions. So here it is.
There are three places deal with our repo in master.cfg: changesources, schedulers and builders, with only changesources and builders that use mercurial specific functions.
In changesources section:
from buildbot.changes.hgpoller import HgPoller
therepo=HgPoller(repourl="/home/user/test/my_project/",
branch='default',
pollInterval=30,
workdir='myrepo')
c['change_source'] = []
c['change_source'].append(therepo)
Here I use HgPoller
, instead of PBChangeSource
. The latter is more sophisticated but also requires more configuration steps (provide a port and yet another username and password).
repourl
must point to the root of your hg repository. Any URL that could be used for "hg pull" or "hg clone" is acceptable. This example involves a local repository, but it could be on a server, then you would specify http something or else.
The default branch
on mercurial is 'default'. pollInterval=30
says every 30 seconds, check for a new commit (this is from a toy example, in reality >30 would be more suitable).
Now the builder, which builds after a commit is detected and passed on by the scheduler(s):
from buildbot.process.factory import BuildFactory
from buildbot.steps.source.mercurial import Mercurial
factory = BuildFactory()
#watch out: this function is Mercurial, NOT Hg
checkout_default = Mercurial(repourl="/home/user/test/my_project/",
defaultBranch='default',
branchType='inrepo',
haltOnFailure = True)
factory.addStep(checkout_default)
# then you add some build instructions and don't forget to import the necessary...
What explains why my thing did not work is that I did not specify defaultBranch
and branchType
. Those keywords are not the same as with Git(), so beware. This is a little tricky as I did not find them in the user manual online, but it's there if you take a moment within the python interpreter:
import buildbot
help(buildbot.steps.source.mercurial)
Also, note that this is the function Mercurial imported from buildbot.steps.source.mercurial
, which is not the same Mercurial function that you would import imported from buildbot.steps.source.Mercurial
. The latter is deprecated (or that which you would use on an older version). My thanks to tomprince from the IRC buildbot channel on freenode for pointing that out.