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

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
Accepted answer

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
}

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

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
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,878 views 19 22
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you