我被赋予了开发其他人编写的 Hudson/Jenkins 插件的责任,而我对此并不陌生...
在其中一个 config.jelly 文件中,有 javascript 代码以这种方式开始:
new Ajax.Request("../../descriptorByName/com.mycompany.jenkins.ScriptExecutionBuilder/getParameters", {
我知道它正在尝试使用 ajax 调用指定 java 类的 getParameters 方法,但如果我能得到其中一些问题的答案,我将不胜感激:
1) url 开始使用的相对当前位置是什么"../"
2) "../../descriptorByName" 是什么意思?似乎“descriptorByName”是一个关键字,而不是指某个文件夹位置...
3)我在哪里可以找到“new Ajax.Request”及其参数的描述以及从上下文中调用的含义詹金斯.jelly?
4)我要解决的问题:当这个 ajax 调用是从“全部”视图中的作业触发时,它工作正常(到达 java 类中的方法),但是,如果我用这个创建一个新的 Jenkins 视图在其中工作,当我从视图中触发上述 ajax 调用时,ajax 调用失败 - java 方法永远不会被执行。我得到如下所示的响应。我如何指定 ajax 请求 url “../../descr ...”,使其在从任何视图(不仅仅是“全部”视图)触发时都能工作?
在名为“SpecialView”的视图中配置作业时触发上述ajax时得到的响应是:
<a href="" onclick="document.getElementById('valerr26').style.display='block';return false">ERROR</a><div id="valerr26" style="display:none"><html><body>
<h1>404 Not Found</h1>
<p>Stapler processed this HTTP request as follows, but couldn't find the resource to consume the request
<pre>
-> evaluate(<hudson.model.Hudson@5ac3cc2d> :hudson.model.Hudson,"/view/SpecialView/descriptorByName/com.mycompany.jenkins.ScriptExecutionBuilder/getParameters")
-> evaluate(((StaplerProxy)<hudson.model.Hudson@5ac3cc2d>).getTarget(),"/view/SpecialView/descriptorByName/com.mycompany.jenkins.ScriptExecutionBuilder/getParameters")
-> evaluate(<hudson.model.Hudson@5ac3cc2d>.getView("SpecialView"),"/descriptorByName/com.mycompany.jenkins.ScriptExecutionBuilder/getParameters")
-> evaluate(<hudson.model.ListView@746cd6da> :hudson.model.ListView,"/descriptorByName/com.mycompany.jenkins.ScriptExecutionBuilder/getParameters")
-> evaluate(<hudson.model.ListView@746cd6da>.getDynamic("descriptorByName",...),"/com.mycompany.jenkins.ScriptExecutionBuilder/getParameters")
hudson.model.ListView@746cd6da.getDynamic("descriptorByName",...)==null. Back tracking.
<font color=red>-> No matching rule was found on <hudson.model.ListView@746cd6da> for "/descriptorByName/com.mycompany.jenkins.ScriptExecutionBuilder/getParameters"</font>
</pre>
<p><hudson.model.ListView@746cd6da> has the following URL mappings, in the order of preference:<ol>
<li>
hudson.model.ListView.doAddJobToView(...) for url=/addJobToView/...
<li>
hudson.model.ListView.doRemoveJobFromView(...) for url=/removeJobFromView/...
<li>
hudson.model.ListView.doCreateItem(...) for url=/createItem/...
<li>
hudson.model.View.doRssAll(...) for url=/rssAll/...
<li>
hudson.model.View.doRssFailed(...) for url=/rssFailed/...
<li>
hudson.model.View.doDoDelete(...) for url=/doDelete/...
<li>
hudson.model.View.doConfigDotXml(...) for url=/config.xml/...
<li>
hudson.model.View.doConfigSubmit(...) for url=/configSubmit/...
<li>
hudson.model.View.doSubmitDescription(...) for url=/submitDescription/...
<li>
hudson.model.View.doRssLatest(...) for url=/rssLatest/...
<li>
TOKEN.groovy for url=/TOKEN
<li>
VIEW.jelly for url=/VIEW
<li>
hudson.model.Saveable.NOOP for url=/NOOP/...
<li>
hudson.model.View.LIST for url=/LIST/...
<li>
hudson.model.View.SORTER for url=/SORTER/...
<li>
hudson.model.View.PERMISSIONS for url=/PERMISSIONS/...
<li>
hudson.model.View.CREATE for url=/CREATE/...
<li>
hudson.model.View.DELETE for url=/DELETE/...
<li>
hudson.model.View.CONFIGURE for url=/CONFIGURE/...
<li>
hudson.model.View.READ for url=/READ/...
<li>
hudson.model.View.NEW_PRONOUN for url=/NEW_PRONOUN/...
<li>
hudson.model.Saveable.NOOP for url=/NOOP/...
<li>
hudson.model.ListView.getJobFilters() for url=/jobFilters/...
<li>
hudson.model.ListView.getIncludeRegex() for url=/includeRegex/...
<li>
hudson.model.ListView.getStatusFilter() for url=/statusFilter/...
<li>
hudson.model.ListView.getDefaultColumns() for url=/defaultColumns/...
<li>
hudson.model.ListView.getItems() for url=/items/...
<li>
hudson.model.ListView.getItems() for url=/items/...
<li>
hudson.model.ListView.getColumns() for url=/columns/...
<li>
hudson.model.ListView.getColumns() for url=/columns/...
<li>
hudson.model.View.getDescriptor() for url=/descriptor/...
<li>
hudson.model.View.getDescriptor() for url=/descriptor/...
<li>
hudson.model.View.getProperties() for url=/properties/...
<li>
hudson.model.View.getActions() for url=/actions/...
<li>
hudson.model.View.getOwner() for url=/owner/...
<li>
hudson.model.View.getDisplayName() for url=/displayName/...
<li>
hudson.model.View.getDescription() for url=/description/...
<li>
hudson.model.View.getUrl() for url=/url/...
<li>
hudson.model.View.getTimeline() for url=/timeline/...
<li>
hudson.model.View.getBuilds() for url=/builds/...
<li>
hudson.model.View.getOwnerItemGroup() for url=/ownerItemGroup/...
<li>
hudson.model.View.getOwnerPrimaryView() for url=/ownerPrimaryView/...
<li>
hudson.model.View.getOwnerViewActions() for url=/ownerViewActions/...
<li>
hudson.model.View.getAllProperties() for url=/allProperties/...
<li>
hudson.model.View.getNewPronoun() for url=/newPronoun/...
<li>
hudson.model.View.getQueueItems() for url=/queueItems/...
<li>
hudson.model.View.getPostConstructLandingPage() for url=/postConstructLandingPage/...
<li>
hudson.model.View.getItemCreatePermission() for url=/itemCreatePermission/...
<li>
hudson.model.View.getAbsoluteUrl() for url=/absoluteUrl/...
<li>
hudson.model.View.getAsynchPeople() for url=/asynchPeople/...
<li>
hudson.model.View.getPeople() for url=/people/...
<li>
hudson.model.View.getApi() for url=/api/...
<li>
hudson.model.View.getComputers() for url=/computers/...
<li>
hudson.model.View.getSearchUrl() for url=/searchUrl/...
<li>
hudson.model.View.getACL() for url=/aCL/...
<li>
hudson.model.View.getApplicablePropertyDescriptors() for url=/applicablePropertyDescriptors/...
<li>
hudson.model.View.getWidgets() for url=/widgets/...
<li>
hudson.model.View.getViewName() for url=/viewName/...
<li>
hudson.model.View.getApproximateQueueItemsQuickly() for url=/approximateQueueItemsQuickly/...
<li>
hudson.model.View.getViewUrl() for url=/viewUrl/...
<li>
hudson.model.View.getIndenter() for url=/indenter/...
<li>
hudson.model.AbstractModelObject.getSearchIndex() for url=/searchIndex/...
<li>
hudson.model.AbstractModelObject.getSearchName() for url=/searchName/...
<li>
hudson.model.AbstractModelObject.getSearch() for url=/search/...
<li>
java.lang.Object.getClass() for url=/class/...
<li>
hudson.model.View.getItem(String) for url=/item/TOKEN/...
<li>
hudson.model.View.getDynamic(String) for url=/dynamic/TOKEN/...
<li>
hudson.model.View.getJob(String) for url=/job/TOKEN/...
<li>
hudson.model.View.getDynamic(String,StaplerRequest,StaplerResponse) for url=/TOKEN/...
</ol>
</body></html>
</div>