pythonhudsonhudson-api

Set Hudson Build Description via Web API


I have a Python script that operates on Hudson builds and would love to be able to set the description of a build programmatically.

I can click "Add Description" on a build's page and fill in the form, how can I POST some data to the same URL that form does?


Solution

  • Figured it out, need to POST the following as form data (content type application/x-www-form-urlencoded) to

    http://myserver/hudson/job/thebuild/10/submitDescription

    {"description": "Some Description for the build"}
    

    In code:

    def set_description(build_url, desc):
        req_data = urllib.urlencode({'description': desc})
        req = urllib2.Request(build_url + '/submitDescription', req_data)
        req.add_header('Content-Type', 'application/x-www-form-urlencoded')
        urllib2.urlopen(req)