Chapter 10 - Using Java: How to run the same report on any JIRA instance

In previous section a BIRT report variable was used to store the JIRA Base URL. This is required to reach JIRA from the Eclipse BIRT Report Designer tool. However, when the BIRT reports runs on JIRA, the JIRA Base URL becomes unnecessary as relative URLs will work... if the Context Path is known. The following JIRA Base URLs have different Context Paths:


  • https://mydomain → The context path is blank 
  • http://localhost:8080/jira → The context  path is /jira

The context path has to  e provided in the BIRT reports relative URL.This requires some scripting to set the JIRA Base URL dynamically. As BIRT is a Java web application running on some Java Application Server like Tomcat, etc. It is possible to access to the remote URL (user's browser) via the Java API.

var contextPath = reportContext.getHttpServletRequest().getContextPath();

contextPath=="/viewer"?"http://localhost:2990":contextPath

Edit the JIRA Base URL variable, click on the Expression Builder icon and copy & paste the script above:


The script uses the HttpServletRequest() Java API to access to the application's context path. It it matches the /viewer path, then it is replaced by the hard coded URL value as the report is being performed from the BIRT Report Designer (Eclipse). Otherwise, the context path will be appended to the relative URL returned by the SQL for JIRA Driver (Atlassian's JAva API). So when the report is deployed on any JIRA instance it will work regardless the JIRA Base URL configuration.