开发者

How to bind an object to URL in Jenkins plugin

I am developing a Jenkins plugin, I have an object that I want to bind it under root url. But I have no idea how to bind.

Suppose my object is MyData which have getData method, I want to bind it to [http://localhost/MyData/data], so that I can get JSON data from this url for my ajax call.

I know the binding mechanism of hudson is Stapler, I try to anno开发者_开发知识库tate ExportedBean on my class, and implements it a ModelObject, but it is still failed.

Any one know how to do this?

I have read below document, hope it can help.

https://wiki.jenkins-ci.org/display/JENKINS/Exposing+data+to+the+remote+API

http://stapler.java.net/apidocs/


You want to create a RootAction.


It could implement Action interface on the Object,

then try to add it to the actions of root Hudson,

like this,

static {
    Hudson.getInstance().getActions().add(new MyData());
}

the binding url is depended on how you implement getUrlName() method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜