Modify

Opened 11 years ago

Closed 6 months ago

#10905 closed defect (fixed)

Hudson 3.0.0 no longer supports /api/python interface

Reported by: c.jones@… Owned by: Dirk Stöcker
Priority: normal Component: HudsonTracPlugin
Severity: major Keywords:
Cc: Trac Release: 0.11

Description (last modified by Ryan J Ollos)

The HudsonTracPlugin requires that hudson makes available the API for python on the URL /api/python at the moment, however now that Eclipse have taken on hudson, and version 3.0.0 has been released, the python API is no longer supported. Once hudson is upgraded to version 3.0.0 you get this error in the TRAC timeline:

Trac Error

Hudson Builds event provider (HudsonTracPlugin) failed:
IOError: Error getting build info from 
'http://myserver:8080/job/jobname/api/python?
tree=builds[building,timestamp,duration,result,description,url,
fullDisplayName,changeSet[items[revision,id,user,author[fullName]]],
culprits[fullName],actions[causes[userName]]]': 
HTTPError: HTTP Error 404: Not Found. 
This most likely means you configured a wrong job_url, username, or password.

See discussion here, that explains the python interface is no longer supported: http://www.eclipse.org/forums/index.php/t/457665/

Apparently though, the api is almost identical to the JSON interface anyway, so perhaps HudsonTracPlugin can be fairly easily modified to point to /api/json instead?

Attachments (1)

hudsontracplugin.diff (2.2 KB) - added by Cinc 9 years ago.
Patch to get ththe plugin to work with Hudson 3.2.x. Note that the path in this file must be corrected properly before applying. Sorry for this inconvenience.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 11 years ago by Ryan J Ollos

Description: modified (diff)

comment:2 Changed 11 years ago by TCF

Without this fix, this plug-in is completely broken (and in fact it breaks the timeline feature in Trac as noted in the bug and thus is actually disruptive). So, made a fix for this myself, replacing the python API with the one for JSON, and also replacing the code used to handle the HTTP calls with the requests library (from python-requests.org). It works fine for my Hudson installation but it probably needs more testing against other configurations of Hudson and Jenkins. Also, since this is my first time writing python, I could use a little coaching in how to make sure I bundle it correctly so it knows the requests library is now a dependency.

Can someone help me with those two items? Then I could give this code to whoever runs this project and have them update it as the next release.

Last edited 11 years ago by TCF (previous) (diff)

comment:3 in reply to:  2 Changed 11 years ago by Ryan J Ollos

Replying to tcfenstermaker:

[...] Also, since this is my first time writing python, I could use a little coaching in how to make sure I bundle it correctly so it knows the requests library is now a dependency.

You'll just need to add an entry in install_requires. Here is an example, and the relevant documentation for setuptools.

Can someone help me with those two items? Then I could give this code to whoever runs this project and have them update it as the next release.

It will probably be easiest if you just attach the code to this ticket, or give us a link to a fork of the code in GitHub, BitBucket, etc...

comment:4 Changed 11 years ago by TCF

Thanks for the help rjollos; I'll try to get to this this week. I'll probably just attach the code to the ticket, as it's only one module. I just need to clean it up a bit.

comment:5 Changed 9 years ago by Cinc

I created a patch to get the plugin to work with Trac 0.12.3 and Hudson 3.2.x:

  • Trac/Plugins/HudsonTrac/HudsonTrac-0.5-py2.7.egg/HudsonTrac/HudsonTracPlugin.py

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    1515import urllib2
    1616import base64
    1717from datetime import datetime
     18import json
    1819
    1920from genshi.builder import tag
    2021from trac.core import *
     
    2930    from trac.timeline.api import ITimelineEventProvider
    3031except ImportError:
    3132    from trac.Timeline import ITimelineEventProvider
    32 try:
    33     from ast import literal_eval
    34 except ImportError:
    35     def literal_eval(str):
    36         return eval(str, {"__builtins__":None}, {"True":True, "False":False})
    3733
     34
    3835class HudsonTracPlugin(Component):
    3936    """
    4037    Display Hudson results in the timeline and an entry in the main navigation
     
    105102        api_url = unicode_quote(self.job_url, '/%:@')
    106103        if api_url and api_url[-1] != '/':
    107104            api_url += '/'
    108         api_url += 'api/python'
     105        api_url += 'api/json'
    109106
    110107        # set up http authentication
    111108        if self.username and self.api_token:
     
    172169                cset = resp.info().getparam('charset') or 'ISO-8859-1'
    173170
    174171                ct   = resp.info().gettype()
    175                 if ct != 'text/x-python':
     172                if ct != 'application/javascript':
    176173                    local_exc = True
    177174                    raise IOError(
    178175                        "Error getting build info from '%s': returned document "
    179                         "has unexpected type '%s' (expected 'text/x-python'). "
     176                        "has unexpected type '%s' (expected 'application/javascript'). "
    180177                        "The returned text is:\n%s" %
    181178                        (self.info_url, ct, unicode(resp.read(), cset)))
    182179
    183                 info = literal_eval(resp.read())
     180                info = json.loads(resp.read())
    184181
    185182                return info, cset
    186183            except Exception:

Note that the revisions are our internal SVN revisions and the path must be adapted properly because the plugin was imported into our private tree.

Sorry for this inconvenience.

Changed 9 years ago by Cinc

Attachment: hudsontracplugin.diff added

Patch to get ththe plugin to work with Hudson 3.2.x. Note that the path in this file must be corrected properly before applying. Sorry for this inconvenience.

comment:6 Changed 9 years ago by Ryan J Ollos

Cc: Ryan J Ollos added

comment:7 Changed 4 years ago by Ryan J Ollos

Cc: Ryan J Ollos removed

comment:8 Changed 6 months ago by Ryan J Ollos

Owner: changed from roadrunner to Dirk Stöcker
Status: newassigned

comment:9 Changed 6 months ago by Dirk Stöcker

As I don't use Hudson, but Jenkins (current version works): Is this still relevant?

comment:10 Changed 6 months ago by Dirk Stöcker

Resolution: fixed
Status: assignedclosed

In 18579:

fix #10905 - support json interface and make it default

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Dirk Stöcker.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.