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
    

I can't get that to work, but I'm no Python hacker.

How long until this is implemented? I was doing this years ago with BuildMaster but somehow over time this basic functionality became impossible?

Is there a Legacy Mercurial extension available that I can use in the meantime?

The legacy source provider is available in the same Mercurial extension. As long as the provider has Log command line arguments disabled, the Admin_ConfigureBuildMaster permission is required to see the URL with the password in it.

If the username or password has special characters that don't work in URLs, they can be encoded. Common characters that cannot be used in the username/password section of a URL without encoding include:

  • \ (use %5C)
  • / (use %2F)
  • @ (use %40)
  • : (use %3A, but don't encode the colon between the username and the password)
  • % (use %25, but only if the percent sign is part of the username/password and not one of the above replacements)
Answer Question