Ask A Question

View Question

I want BuildMaster to deploy to our DEV environment automatically whenever someone pushes a new revision to our Mercurial repository. When I go to the "Release Package Triggers" section under the Settings for my application (http://buildmaster/applications/1/schedules), I click "Create New SCM Trigger". BuildMaster says there are no Source Control Providers set up in BuildMaster. This is true, but I do have the Mercurial extension installed. Do I have to configure a Source Control Provider for this? I'd like to avoid doing so because they are deprecated. In addition, it seems like the Source Control Provider dialog doesn't allow you to specify a resource credential, so I would have to inject the credentials in the Remote URL field ("http://user@pass:my.repo.com"). There are two reasons I don't want to do this:

  1. I don't want to expose the credentials like that in BuildMaster.
  2. When I tried using the http://user@pass:my.repo.com syntax, BuildMaster couldn't parse it -- probably because the password contains some unusual characters.

Product: BuildMaster
Version: 5.6.11

Hello Glenn,

For now, the “Release Package Triggers” only work with legacy source control providers. It’s certainly on our roadmap to update this module so that there’s a more natural integration point.

But until then, the best solution is to use a changegroup hook in Mercurial, and the Release/Package API. To do this,

  1. Create a key at http://buildmaster/administration/api-keys with at least the Grant access to Release & Deployment API box checked.
  2. Create a file with the following contents somewhere in the PYTHONPATH of your Mercurial server:
    import urllib
    import httplib
    import json
    
    api_key = 'YOUR_API_KEY'
    app_id = 1
    
    def create_package(ui, repo, **kwargs):
        h = httplib.HTTPConnection('buildmaster')
        h.request('GET', '/api/releases?' + urllib.urlencode({'key': api_key, 'applicationId': app_id, 'status': 'active'}))
        releases = json.loads(h.getresponse().read())
        h.request('POST', '/api/releases/packages/create?' + urllib.urlencode({'key': api_key, 'releaseId': releases[0]['id']}))
        resp = h.getresponse()
        if resp.status != 200:
            print resp.status, resp.reason
            print resp.read()
        else:
            resp.read()
        h.close()
    
  3. Add this to .hg/hgrc on the Mercurial server:
    [hook]
    changegroup.buildmaster = python:path.to.create_package
    
Answer Question