How can I find jira issues that are linkes to a specific Confluence page?

Ruby Boyarski February 18, 2013

We have User Stories specified in Confluence and the corresponding development and testing acitivities managed in JIRA. They are linked via the "Wiki page" link that supports linking any JIRA issue with a Confluence page. We would like to show all related JIRA issues on the Confluence page itself using the JIRA issues macro, which allows specifiny a JQL to find the issues to present.

Is there a way to find all these related JIRA issues with JQL?

I was thinking there should be a way to search links via their values, but no luck. We also have the JQL Tricks plugin, which doesn't help here, it seems.

2 answers

1 accepted

0 votes
Answer accepted
Ruby Boyarski February 19, 2013

OK, I found a way, using the suggestion script runner plugin by C.Feysal. Thanks very much mate!

Here's the code in the getQuery method of the scripted JQL function (you essentially put any SQL statement there that returns issue ids) - I called it "linkedToPage"

Query getQuery(QueryCreationContext queryCreationContext, FunctionOperand operand, TerminalClause terminalClause) {   
	ComponentManager componentManager = ComponentManager.getInstance()
	def delegator = (DelegatorInterface) componentManager.getComponentInstanceOfType(DelegatorInterface.class)
	String helperName = delegator.getGroupHelperName("default");

	def sqlStmt = """select issueid from remotelink where url = 'https://YOUR_CONFLUENCE_DOMAIN/pages/viewpage.action?pageId=""" + operand.args[0] + """'"""

	Connection conn = ConnectionFactory.getConnection(helperName);
	Sql sql = new Sql(conn)
	def booleanQuery = new BooleanQuery()
	sql.eachRow(sqlStmt) {
                booleanQuery.add(new TermQuery(new Term("issue_id", "${it.issueid}")), BooleanClause.Occur.SHOULD)
	}
	return booleanQuery
}
0 votes
C_ Faysal
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 18, 2013

i never tried so this is only a guess...but with script runner plugin you can extend your jql to sth like

maybe the "hasLinks" will be what you desire?

regards

Ruby Boyarski February 18, 2013

Thanks for the quick reply, but I don't think this would work. This functionality is similar what the JQL Tricks plugin provides, which is searching by link type.

In this case I need the link value. Further to that, based on the JIRA DB these types of links are not regular links. They are implemented as remote link, which may mean they have a different way of retrieving them. Not sure about that, though...

Suggest an answer

Log in or Sign up to answer