Stapler Web Method не вызывается в плагине jenkins
Согласно этой документации очень легко вызывать WebMethod при расширении Jenkins. Другие примеры очень просты.
Вот мой пример:
@WebMethod(name = "bestResults")
public void doBestResults(StaplerRequest req, StaplerResponse rsp) throws MalformedURLException {
System.out.println("WebMethod called!");
final File file = new File(this.resultsZipFilePath);
if (file.exists()) {
downloadZipResultsFile(rsp);
} else {
rsp.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
}
private void downloadZipResultsFile(final StaplerResponse response) {
final File file = new File(this.resultsZipFilePath);
response.setContentType("application/zip");
try (final ServletOutputStream sos = response.getOutputStream(); final FileInputStream fis = new FileInputStream(file)) {
int byteRead;
while ((byteRead = fis.read()) != -1) {
sos.write(byteRead);
}
} catch (IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
"Вебметод называется!" никогда не печатается. URL вызывается нажатием на тег a следующего шаблона желе:
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<t:summary icon="/plugin/org.test.jenkinsplugin/icons/logo_my_logo.png">
<a href="bestResults">Download Best Results</a>
</t:summary>
</j:jelly>
Браузер покидает сайт, на котором ссылка была нажата, примерно на 2 секунды, а затем просто возвращается. Нет сообщений об ошибках или журналов с информацией о том, что пошло не так.
Почему мой WebMethod не вызывается?