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?
Community moderators have prevented the ability to post new answers.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.