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

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,103 views 13 19
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot