Adding $JOB_URL/foo REST endpoint from a plugin

16 views
Skip to first unread message

Magnus Bäck

unread,
Feb 9, 2021, 4:30:10 PM2/9/21
to Jenkins Developers
I'm trying to add a REST endpoint that mirrors the standard $JOB_URL/buildWithParameters but supports additional URL parameters that I'll translate to a cause when starting a build.

I've created an Action containing

@RequirePOST @WebMethod(name = "") public void doBuildWithEiffelLinks(...) { ... }
public String getUrlName() { return "buildWithEiffelLinks"; }

and with that a POST to $JOB_URL/buildWithEiffelLinks/ works, but if I omit the trailing slash a 302 response is returned. Is there a way to attach the webmethod to the root of the item or do I have to live with the trailing slash or use a URL like $JOB_URL/eiffel/buildWithLinks? Or is this the wrong approach entirely?

Thanks,
Magnus

Jesse Glick

unread,
Feb 9, 2021, 5:37:02 PM2/9/21
to Jenkins Dev
On Tue, Feb 9, 2021 at 4:30 PM Magnus Bäck <magnu...@axis.com> wrote:
@RequirePOST @WebMethod(name = "") public void doBuildWithEiffelLinks(...) { ... }

Drop the `@WebMethod` and just use `doIndex`.

Is there a way to attach the webmethod to the root of the item or do I have to live with the trailing slash or use a URL like $JOB_URL/eiffel/buildWithLinks?

 You need to use either the `buildWithEiffelLinks/` or `eiffel/buildWithLinks` style.
Reply all
Reply to author
Forward
0 new messages