Jira Service Desk P2 web-item does not include context path

I created a web-item in my P2 plugin descriptor as follows:

...
    <web-item
            key="sd-portal-request-view-action-link"
            i18n-name-key="sd-portal-request-view-action-link.name"
            name="The Link Name"
            section="servicedesk.portal.request.actions"
            weight="20">
        <label key="sd-portal-request-view-action-link.label"/>
        <link linkId="issue-operation-link">
            /page/issue/dialog/link/iframe
        </link>
        <icon height="16" width="16">
            <link>/assets/images/icon.png</link>
        </icon>
    </web-item>
...

Everything works fine except that JSD does not include the context path in the relative links of the web-item itself and the link of icon.

Expected:
https://myhost.com/**jira**/page/issue/dialog/link/iframe

Actual:
https://myhost.com/page/issue/dialog/link/iframe

jira or whatever the configured context path may be is not included in the final links.

Do I miss something or has anyone seen this before and knows how to fix it? I also have web-item for the Jira issue view and there it works as expected.

(seems JSD sources are not provided with the license otherwise I would have had a look there)

IIRC you should have an instance of JiraHelper in the context of the Atlassian-Plugin.xml file. This variable is named ‘helper’. Thus, you should be able to use $helper.request.contextPath in order to obtain the context path, if it exists.

@steve.behnke Thanks for your reply! I tried this but it doesn’t work. It does not resolve $helper.request.contextPath, so I assume $helper might not be available. Also couldn’t find any docs that explain available context parameters in atlassian-plugin.xml.

It’s kind of weird that JSD and Jira do it differently.

Found the right context variable:

You can use $req.contextPath to include the context path.

Like normal for Jira Server, you had to go through 7000 pages, community posts and legacy documentation to end up with this Confluence documentation that provides the right hints. :roll_eyes::face_with_raised_eyebrow:

Thanks for directing me in the right direction @steve.behnke!

Haha. Hey I’m glad you figured it out, I just did myself. The documentation we were looking for, for Jira Velocity Contexts is here: https://developer.atlassian.com/server/jira/platform/jira-templates-and-jsps/

I was also able to reproduce that issue myself! That is quite strange. I’m not sure why that is either, and it’s unfortunate that there’s a unique case like that. :confused:

Oh good, so the documentation does exist for Jira as well :+1:

Yeah, I also don’t understand why that is. Maybe just an implementation difference. At least there is a simple workaround :smile:

1 Like

How do you add the context in plugin descriptor ?

 <link linkId="issue-operation-link">
            /page/issue/dialog/link/iframe

I understand your solution will work for velocity files, but say if I need to access directly from a web-item , the context remains unavailable right ?

@ajay try this

<link linkId="issue-operation-link">
            $req.contextPath/page/issue/dialog/link/iframe
</link>
1 Like

@tbinna Thanks it works :grinning: . It was not clear to me that the $req.contextPath can be used in the descriptor file .

Cheers
Ajay

1 Like