*/api/json fails for a new Jenkins plugin

44 visningar
Hoppa till det första olästa meddelandet

Daniel Mercier

oläst,
10 aug. 2017 15:37:142017-08-10
till Jenkins Developers
Hi everyone,

I created a new Jenkins plugin and while everything seems to work. The API/JSON fails consistently. The same behavior can be experienced with the pugin: Test_Analyzer_Plugin.

The answer on my plugin comes as a 404:

404 Not Found

Stapler processed this HTTP request as follows, but couldn't find the resource to consume the request

-> evaluate(<hudson.model.Hudson@a25d803> :hudson.model.Hudson,"/job/test/BenchmarkTable/api/json")
-> evaluate(((StaplerProxy)<hudson.model.Hudson@a25d803>).getTarget(),"/job/test/BenchmarkTable/api/json")
-> evaluate(<hudson.model.Hudson@a25d803>.getJob("test"),"/BenchmarkTable/api/json")
-> evaluate(<hudson.model.FreeStyleProject@6135ae8a[test]> :hudson.model.FreeStyleProject,"/BenchmarkTable/api/json")
-> evaluate(<hudson.model.FreeStyleProject@6135ae8a[test]>.getDynamic("BenchmarkTable",...),"/api/json")
-> evaluate(<org.jenkinsci.plugins.benchmark.BenchmarkProjectAction@5dcde26d> :org.jenkinsci.plugins.benchmark.BenchmarkProjectAction,"/api/json")
-> No matching rule was found on <org.jenkinsci.plugins.benchmark.BenchmarkProjectAction@5dcde26d> for "/api/json"

<org.jenkinsci.plugins.benchmark.BenchmarkProjectAction@5dcde26d> has the following URL mappings, in the order of preference:

  1. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.setResultSelected(...) for url=/setResultSelected/...
  2. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.ResetClock(...) for url=/ResetClock/...
  3. TOKEN.groovy for url=/TOKEN
  4. VIEW.jelly for url=/VIEW
  5. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.getDisplayName() for url=/displayName/...
  6. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.getProject() for url=/project/...
  7. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.getUrlName() for url=/urlName/...
  8. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.getIconFileName() for url=/iconFileName/...
  9. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.getResultPageURL() for url=/resultPageURL/...
  10. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.getRootPageURL() for url=/rootPageURL/...
  11. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.getNumberOfHeads() for url=/numberOfHeads/...
  12. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.getRawTable() for url=/rawTable/...
  13. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.getCondensedTable() for url=/condensedTable/...
  14. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.getContentAvailable() for url=/contentAvailable/...
  15. org.jenkinsci.plugins.benchmark.BenchmarkProjectAction.getCore() for url=/core/...
  16. java.lang.Object.getClass() for url=/class/...

If anyone faced the same issue, any help will be greatly appreciated.

Best regards,

Daniel Mercier

Markus Winter

oläst,
10 aug. 2017 15:49:522017-08-10
till jenkin...@googlegroups.com
you need a method getApi() that returns an Api [1]

public Api getApi() {
        return new Api(this);
    }


[1] http://javadoc.jenkins.io/hudson/model/Api.html

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/e1c4bec7-99e0-4c37-bd8e-d8a84043490b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Mercier

oläst,
10 aug. 2017 17:00:052017-08-10
till Jenkins Developers, m_wi...@gmx.de
Thank you very much.

Daniel Mercier

Robert Sandell

oläst,
11 aug. 2017 05:50:402017-08-11
till jenkin...@googlegroups.com, Markus Winter
But it looks like your action is attached to a job. So instead you could/should just put @Exported on the getters in the action that you want exposed and then get it via the /job/test/api/json endpoint instead.

/B

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/b9453824-0c36-40b5-a974-673ca191d4a2%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees Inc.
Svara alla
Svara författaren
Vidarebefordra
0 nya meddelanden