Apply to Jenkins.
@@ -8,9 +8,9 @@ | ||
8 | 8 | version = '0.4', |
9 | 9 | author = "Itou Akihiro", |
10 | 10 | author_email = "itou.akihiro@gmail.com", |
11 | - description = "An advanced trac plugin to cooperate with hudson. Forked from HudsonTrac Plugin (c) Ronald Tschalär. http://trac-hacks.org/wiki/HudsonTracPlugin", | |
11 | + description = "An advanced trac plugin to cooperate with jenkins. Forked from HudsonTrac Plugin (c) Ronald Tschalär. http://trac-hacks.org/wiki/HudsonTracPlugin", | |
12 | 12 | license = "BSD", |
13 | - keywords = "trac builds hudson", | |
13 | + keywords = "trac builds jenkins", | |
14 | 14 | url = "http://sourceforge.jp/projects/shibuya-trac/wiki/HudsonTracPlusPlugin", |
15 | 15 | |
16 | 16 | packages = ['HudsonTracPlus'], |
@@ -113,7 +113,7 @@ | ||
113 | 113 | - INavigationContributor |
114 | 114 | - ITimelineEventProvider |
115 | 115 | - ITemplate Provider |
116 | - - IWkikiMacroProvider | |
116 | + - IWikiMacroProvider | |
117 | 117 | |
118 | 118 | INavigationContributor is for making navbar menu. |
119 | 119 |
@@ -125,13 +125,13 @@ | ||
125 | 125 | ''' |
126 | 126 | implements(INavigationContributor, ITimelineEventProvider, ITemplateProvider, IWikiMacroProvider) |
127 | 127 | |
128 | - hudson_url = Option('hudsonplus', 'hudson_url', 'http://localhost:8010/hudson/', | |
129 | - 'The url of the hudson top page. This must be an ' + | |
128 | + hudson_url = Option('hudsonplus', 'hudson_url', 'http://localhost:8010/jenkins/', | |
129 | + 'The url of the jenkins top page. This must be an ' + | |
130 | 130 | 'absolute url. This plugin uses this to get information ' + |
131 | - 'through Hudson Remote API.') | |
131 | + 'through Jenkins Remote API.') | |
132 | 132 | |
133 | - nav_url = Option('hudsonplus', 'main_page', '/hudson/', | |
134 | - 'The url of the hudson main page to which the trac nav ' + | |
133 | + nav_url = Option('hudsonplus', 'main_page', '/jenkins/', | |
134 | + 'The url of the jenkins main page to which the trac nav ' + | |
135 | 135 | 'entry should link; if empty, no entry is created in ' + |
136 | 136 | 'the nav bar/timeline/wikimacro. This may be a relative url.') |
137 | 137 | jobs = ListOption('hudsonplus', 'jobs', '', sep=',' , |
@@ -138,13 +138,13 @@ | ||
138 | 138 | doc='Jobs to display on timeline separated by comma. ' + |
139 | 139 | 'If you don\'t specify this at all, show all jobs.') |
140 | 140 | disp_tab = BoolOption('hudsonplus', 'display_in_new_tab', 'false', |
141 | - 'Open hudson page in new tab/window') | |
142 | - navi_label = Option('hudsonplus', 'navigation_label', 'Hudson', | |
141 | + 'Open Jenkins page in new tab/window') | |
142 | + navi_label = Option('hudsonplus', 'navigation_label', 'Jenkins', | |
143 | 143 | 'The label of navigation tab.') |
144 | 144 | username = Option('hudsonplus', 'username', '', |
145 | - 'The username to use to access hudson') | |
145 | + 'The username to use to access Jenkins') | |
146 | 146 | password = Option('hudsonplus', 'password', '', |
147 | - 'The password to use to access hudson') | |
147 | + 'The password to use to access Jenkins') | |
148 | 148 | |
149 | 149 | def __init__(self): |
150 | 150 | pwdMgr = urllib2.HTTPPasswordMgrWithDefaultRealm() |
@@ -175,7 +175,11 @@ | ||
175 | 175 | |
176 | 176 | def get_htdocs_dirs(self): |
177 | 177 | from pkg_resources import resource_filename |
178 | - return [('HudsonTracPlus', resource_filename(__name__, 'htdocs'))] | |
178 | + try: | |
179 | + dir = resource_filename(__name__, 'htdocs') | |
180 | + except: | |
181 | + return [] | |
182 | + return [('HudsonTracPlus', dir)] | |
179 | 183 | |
180 | 184 | # ITimelineEventProvider methods |
181 | 185 | def get_timeline_filters(self, req): |
@@ -227,19 +231,20 @@ | ||
227 | 231 | |
228 | 232 | # IWikiMacroProvider method |
229 | 233 | def get_macros(self): |
230 | - """RefHudsonBuild""" | |
234 | + """RefHudsonBuild/RefJenkinsBuild""" | |
231 | 235 | yield 'RefHudsonBuild' |
236 | + yield 'RefJenkinsBuild' | |
232 | 237 | |
233 | 238 | def get_macro_description(self, name): |
234 | - return '''Make an extra-link to hudson build''' | |
239 | + return '''Make an extra-link to jenkins build''' | |
235 | 240 | |
236 | 241 | def render_macro(self, req, name, content): |
237 | 242 | return self.expand_macro(None, name, content) |
238 | 243 | |
239 | 244 | def expand_macro(self, formatter, name, content): |
240 | - if name == 'RefHudsonBuild': | |
245 | + if name == 'RefHudsonBuild' or name == 'RefJenkinsBuild': | |
241 | 246 | if self.nav_url: |
242 | - return get_build_ref_markup(self.nav_url, self.jobs, content) | |
247 | + return get_build_ref_markup(self.nav_url, self.jobs, content, self.navi_label) | |
243 | 248 | |
244 | 249 | def get_job_url(job_url, hudson_url): |
245 | 250 | """Return the job url to use api access. |
@@ -385,7 +390,7 @@ | ||
385 | 390 | else: |
386 | 391 | return unicode(build['description'], 'utf-8') + ' at ' + formated_build_time |
387 | 392 | |
388 | -def get_build_ref_markup(nav_url, jobs, content): | |
393 | +def get_build_ref_markup(nav_url, jobs, content, label): | |
389 | 394 | '''Return build reference markup expanded by RefHudsonBuild macro. |
390 | 395 | |
391 | 396 | ex1. [[RefHudsonBuild(j3, 1)] |
@@ -403,7 +408,7 @@ | ||
403 | 408 | '<a class="ext-link" href="spam/job/><"/1/"><span class="icon"></span>Hudson: ><"#1</a>' |
404 | 409 | |
405 | 410 | ''' |
406 | - FORMAT = '<a class="ext-link" href="%sjob/%s/%s/"><span class="icon"></span>Hudson: %s#%s</a>' | |
411 | + FORMAT = '<a class="ext-link" href="%sjob/%s/%s/"><span class="icon"></span>%s: %s#%s</a>' | |
407 | 412 | args = map(lambda x: x.strip(), str(content).split(',')) |
408 | 413 | if len(args) == 1: |
409 | 414 | if len(jobs) == 0: |
@@ -414,4 +419,4 @@ | ||
414 | 419 | job_name = Markup.escape(args[0]) |
415 | 420 | job_no = Markup.escape(args[1]) |
416 | 421 | |
417 | - return Markup(FORMAT % (nav_url, job_name, job_no, job_name, job_no)) | |
422 | + return Markup(FORMAT % (nav_url, job_name, job_no, label, job_name, job_no)) |
@@ -10,12 +10,12 @@ | ||
10 | 10 | def test_default_opt_hudson_url(self): |
11 | 11 | env = EnvironmentStub() |
12 | 12 | htpp = HudsonTracPlusPlugin(env) |
13 | - assert 'http://localhost:8010/hudson/' == htpp.hudson_url | |
13 | + assert 'http://localhost:8010/jenkins/' == htpp.hudson_url | |
14 | 14 | |
15 | 15 | def test_default_opt_nav_url(self): |
16 | 16 | env = EnvironmentStub() |
17 | 17 | htpp = HudsonTracPlusPlugin(env) |
18 | - assert '/hudson/' == htpp.nav_url | |
18 | + assert '/jenkins/' == htpp.nav_url | |
19 | 19 | |
20 | 20 | def test_default_opt_jobs(self): |
21 | 21 | env = EnvironmentStub() |