Hi,

Thanks for your interest. We need to put more docs on these topics, 
something we will get fixed soon.

You can use ApiRoutable to add your routes to BlueOcean API root: 
/blue/rest/. See BlueOrganizationContainer for reference. It adds 
organizations to /blue/rest/ path. 

>From what you have described, if your action is added to specific Job type 
then /blue/rest/organizations/jenkins/pipelines/mypipeline/ should list 
that action and the action's endpoints should be rooted at 
/blue/rest/organizations/jenkins/pipelines/mypipeline/actions/{yourAction.urlName}/
 
(you can find this link in  _links object for 'actions' when GET 
/blue/rest/organizations/jenkins/pipelines/mypipeline/ is called). 

For example:

Here is TestResultProjectAction in pipeline response. As you can see this 
action endpoint urlName is 'test' and so its rooted at that, that 
is /blue/rest/organizations/jenkins/pipelines/blueocean/branches/PR-752/test/. 
Please note its a multi branch project so actions are rooted in side 
branches, otherwise it could simply appear inside .../pipelines/.

{..."actions":[{"_class": "hudson.tasks.test.TestResultProjectAction","
_links": {"self": {"_class": "io.jenkins.blueocean.rest.hal.Link","href": "
/blue/rest/organizations/jenkins/pipelines/blueocean/branches/PR-752/test/"}
},"urlName": "test"}]...}

You are able to use using index because actions are returned as generic 
Container<>, but recommended way is to access them using action's urlName.






On Friday, January 27, 2017 at 9:13:33 AM UTC-8, Gijs wrote:
>
> Hi, I'm exploring the Jenkins source code a bit to learn its internals and 
> perhaps in the future be able to contribute a bit. I've written a couple of 
> simple test-plugins during my exploration.
>
> Right now I'm looking into how to write a plugin for blue ocean, and I've 
> got some simple stuff working, like adding a rest endpoint (By 
> implementing io.jenkins.blueocean.rest.ApiRoutable), adding a link to the 
> pipeline page with the jenkins.pipeline.detail.header.action extension 
> point and adding a route using the jenkins.main.routes extension point. But 
> this has led me to some things I'm not sure how to do, so here goes:
>
>  - How do you add a route in the existing hierarchy of the routing table? 
> I could add a separate route using the jenkins.main.routes extension point 
> but that falls completely outside of the existing hierarchy so (unless I'm 
> mistaken) you lose all context (which organization, pipeline, run you're 
> in).
>  - I added an Action to a Job via a TransientActionFactory and annotated 
> the Action with @ExportedBean, I could now get rest data by implementing 
> @TreeResponse @GET @WebMethod(name = "") public Object getSomeData() { ... 
> } on the action. This seems to work, but the actions property in the 
> /blue/rest/organizations/jenkins/pipelines/mypipeline/ seems to not work, 
> instead of 
> /blue/rest/organizations/jenkins/pipelines/mypipeline/my-action-url I need 
> to go to 
> /blue/rest/organizations/jenkins/pipelines/mypipeline/actions/1/action 
> (where 1 is the index of the action in the actions property). Is this 
> something that still needs to be fixed or am I doing it wrong?
>  
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/ec86cfc3-5a84-4c86-882b-c02d409552d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to