Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Should I be reconstructing URLs to create a stash.repository.nav Web Item?

Graham Lea February 14, 2014

I've just started writing a plugin (my first) that adds a stash.repository.nav Web Item.

I read in the docs that the link is not absolute by default, so I have written my link as 'hello', expecting that the link URL on http://localhost:7990/stash/projects/PROJECT_1/repos/testrepo/browsewould point to http://localhost:7990/stash/projects/PROJECT_1/repos/testrepo/hello, but instead the link is http://localhost:7990/stashhello.

So now I'm thinking I have to use the Project and Repository objects to reconstruct a URL path similar to above using a Velocity template in the link. Is that the right approach, or have I missed something that allows me to simply create a relative URL?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 14, 2014

Hi Graham.

As far as I can tell it's relative to the context of your application, not to the current page.

Most of the Stash web-items look like this, building up the full (relative) path to whatever entity they are linking to:

<web-item ...>
    <link>${navBuilder.repo($repository).buildRelNoContext()}</link>
</web-item>

Where $repository is part of the Context map that is evaluated by Velocity. You can add your own <context-provider> to add your own values too of course.

I suspect you would need to prefix that with your own plugin servlet/rest path, depending on your requirements.

Does that help?

Charles

Graham Lea February 15, 2014

Thanks, Charles, that's exactly what I wanted to know.

I'm guessing your suggestion that I use a prefix means that I will need to use a prefix, i.e. Stash will not like me if I try to hook a servlet up to

/projects/*/repos/*/hello

and I should just be doing something like

/plugins/hello/projects/*/repos/*

from the start. Is that right?

Cheers,

Graham.

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 15, 2014

Hi Graham,

That's right. There isn't any (safe) way to extend our existing URLs. Even our own Stash plugins, like branch permissions, have their own servlet prefix. (It's definitely not ideal)

Unrelated, but depending on what you're doing, there is a convenient way to "inject" a project/repository/pull-request object in to a REST method if that's what you need:

https://answers.atlassian.com/questions/260768/add-parameters-to-rest-call

Cheers,

Charels

TAGS
AUG Leaders

Atlassian Community Events