Hi, thanks for replying, however neither point is completely clear to me.
My first question was perhaps not stated completely clearly (the part of
injecting a REST route using ApiRoutable I had already figured out) but my
question was meant to be about the Javascript/React side of things, there
it uses the 'jenkins.main.routes' extension point to concatenate all the
extensions' Routing tables together in the makeRoutes function. And there
it seems to not be possible to inject something inside of the hierarchy,
sure I could add the following:
<Route path="/organizations/:organization/pipeline/:pipeline/my-page"
componenet={MyComponent}/>
But I'd lose all the components and context that other urls there have, and
I'd have to build that up manually myself. Maybe this is the wrong way to
go about this, and as BlueOcean is still pretty new maybe all the ways of
extending it haven't been worked out yet. I'm just curious to know how one
would go about adding information/actions/charts/what have you to jobs and
runs as a lot of plugins do today.
As for my second question, none of those links I got to work, that's why I
ended up using the /actions/{index}/ endpoint. And from what I understand
(and see in the Stapler 404 page) `/blue/rest/organizations/jenkins/
pipelines/blueocean/branches/PR-752/test/` would take the BranchImpl for
PR-752 and try to get "test" from it, but BranchImpl or its ancestors do
not implement any method to dynamically get an action based on its urlName
as far as I can find it, it also doesn't implement StaplerProxy. Am I
looking in the wrong place?
On Friday, January 27, 2017 at 9:04:30 PM UTC+1, vivek wrote:
> 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/1432fff4-990a-4b09-b36c-07465f0e69df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.