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

This widget could not be displayed.

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
This widget could not be displayed.

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?


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
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

135 views 1 3
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