I am using latest bitbucket server and trying to add some configuration form to repository settings page under add-ons section. This configuration is specific for each repository. I was able to add a web-tem which shows up as a link under add-ons in repository settings. Now i would like link this web-item to a servlet to render the configuration page (built using soy template). when my link is clicked, It shows up a 404. I couldn't find any doc related to this configuration.
1. What is the <link> value that i should be using to invoke my servlet? Here is what i am using.
<web-item name="My Configuration Tab" key="My-configuration-tab" section="bitbucket.repository.settings.panel/repository-settings-addons-section">
<label key="My Configuration">My Configuration</label>
<link linkId="My-configuration-tab-link">/projects/${project.key}/repos/${repository.slug}/settings/configservlet</link>
<tooltip key="My-configuration-tab.tooltip">My Configuration</tooltip>
</web-item>
2. What is the corresponding url-pattern i should be using ? Here's what i have
<servlet name="My Config Servlet Module" i18n-name-key="my-config-servlet.name" key="my-config-servlet" class="com.my.servlet.MyConfigServlet">
<description key="my-config-servlet.description">The My Config Servlet Plugin</description>
<url-pattern>/settings/configservlet</url-pattern>
</servlet>
3. What is the meta tag that i should be using in soy template? Here's what i have
<meta name="decorator" content="bitbucket.repository.settings">
Other than above 3, are there any other things i need to have to get this working?
You’re using a servlet so the path to it rooted at /plugins/servlet
so the link should be:
/plugins/servlet/settings/configservlet
It is still giving the 404 error. I tried this.
1. Inside web-item i gave this link path
<link linkId="my-configuration-tab-link">/plugins/servlet/settings/configservlet</link>
2. Inside the servlet i gave the below path.
<url-pattern>*/settings/configservlet</url-pattern>
Did i miss anything? does the above path in <link> links to repository settings? What is the best way to debug this?
Thanks for the help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Make the url-pattern in the servlet be:
<url-pattern>/settings/configservlet</url-pattern>
By specifying
<url-pattern>*/settings/configservlet</url-pattern>
-the actual url pattern is /plugins/servlet/*/settings/configservlet
- which you probably don't want :)
The other piece I would suggest is to have your add-on name in the url-pattern somewhere to avoid another add-on collding with your paths ( for example I try to have the Wittified add-ons at /wittified/....). This way likelihood of somebody else having the same path is a lot smaller :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Daniel. that worked. In addition to the above one, i had to make few more changes in my soy template and in the servlet.
- I have added the necessary meta tags required for the repository settings decorater in the soy template.
<meta name="decorator" content="bitbucket.repository.settings">
<meta name="projectKey" content="{$repository.project.key}">
<meta name="repositorySlug" content="{$repository.slug}">
- I have declared the repository param in the soy template.
/**
* @param repository Repository object
*/
- I have passed in the project and repository names as part of the <link> tag and used those inside my servlet to get a repository instance like this and passed it on to the renderer.
<link linkId="my-configuration-tab-link">/plugins/servlet/settings/myconfig/${project.key}/${repository.slug}</link>
String pathInfo = req.getPathInfo();
String[] path = pathInfo.split("/");
String project = path[path.length-2];
String repo = path[path.length-1];
Repository repository = repositoryService.getBySlug(project, repo);
Hope this info helps someone with similar needs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Try to use
<url-pattern>*/settings/configservlet</url-pattern>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry that didn't wok. it still gives 404. I was building on top of decorator-plugin example. if i use the <link> , <url-pattern>, <meta> tags from that example it works but opens in user accounts section. Any other suggestions?
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.