Opened 12 years ago
Closed 14 months ago
#10905 closed defect (fixed)
Hudson 3.0.0 no longer supports /api/python interface
Reported by: | Owned by: | Dirk Stöcker | |
---|---|---|---|
Priority: | normal | Component: | HudsonTracPlugin |
Severity: | major | Keywords: | |
Cc: | Trac Release: | 0.11 |
Description (last modified by )
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)
Change History (11)
comment:1 Changed 12 years ago by
Description: | modified (diff) |
---|
comment:3 Changed 11 years ago by
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
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 10 years ago by
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
15 15 import urllib2 16 16 import base64 17 17 from datetime import datetime 18 import json 18 19 19 20 from genshi.builder import tag 20 21 from trac.core import * … … 29 30 from trac.timeline.api import ITimelineEventProvider 30 31 except ImportError: 31 32 from trac.Timeline import ITimelineEventProvider 32 try:33 from ast import literal_eval34 except ImportError:35 def literal_eval(str):36 return eval(str, {"__builtins__":None}, {"True":True, "False":False})37 33 34 38 35 class HudsonTracPlugin(Component): 39 36 """ 40 37 Display Hudson results in the timeline and an entry in the main navigation … … 105 102 api_url = unicode_quote(self.job_url, '/%:@') 106 103 if api_url and api_url[-1] != '/': 107 104 api_url += '/' 108 api_url += 'api/ python'105 api_url += 'api/json' 109 106 110 107 # set up http authentication 111 108 if self.username and self.api_token: … … 172 169 cset = resp.info().getparam('charset') or 'ISO-8859-1' 173 170 174 171 ct = resp.info().gettype() 175 if ct != ' text/x-python':172 if ct != 'application/javascript': 176 173 local_exc = True 177 174 raise IOError( 178 175 "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'). " 180 177 "The returned text is:\n%s" % 181 178 (self.info_url, ct, unicode(resp.read(), cset))) 182 179 183 info = literal_eval(resp.read())180 info = json.loads(resp.read()) 184 181 185 182 return info, cset 186 183 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 10 years ago by
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 10 years ago by
Cc: | Ryan J Ollos added |
---|
comment:7 Changed 5 years ago by
Cc: | Ryan J Ollos removed |
---|
comment:8 Changed 14 months ago by
Owner: | changed from roadrunner to Dirk Stöcker |
---|---|
Status: | new → assigned |
comment:9 Changed 14 months ago by
As I don't use Hudson, but Jenkins (current version works): Is this still relevant?
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 (frompython-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 therequests
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.