Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Find a link to Confluence from current issue of Jira.

zaharovvv_suek_ru
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.
June 6, 2018

Hello, guys!

We are using ScriptRunner. I would like to check whether the current issue has a link to confluence.


I can see other links, however the following code does not show a confluence link:

package com.onresolve.jira.groovy.test.scriptfields.scripts
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.worklog.WorklogManager
import com.atlassian.jira.bc.issue.worklog.TimeTrackingConfiguration

def worklogManager = ComponentAccessor.getComponent(WorklogManager)
def workLogs = worklogManager.getByIssue(issue)
def issueLinkManager = ComponentAccessor.getIssueLinkManager()

issueLinkManager.getOutwardLinks(issue.id).each { issueLink ->
    log.debug(issueLink)
}

 

How is it possible to check whether the current issue has a link to confluence?

1 answer

1 accepted

2 votes
Answer accepted
Tarun Sapra
Community Champion
June 6, 2018

You would have to use "RemoteLinkManager" instead, as Jira issue is connected to confluence via remote links and not via normal issue links

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.RemoteIssueLinkManager
import org.apache.log4j.Level
import org.apache.log4j.Logger

Logger log = Logger.getLogger("com.onresolve")
log.setLevel(Level.INFO)

def issue = ComponentAccessor.issueManager.getIssueObject("<your issue key>")
def RemoteIssueLinkManager remoteIssueLinkManager = ComponentAccessor.getComponent(RemoteIssueLinkManager);
def remoteLInks = remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue)

remoteLInks.each {
log.info it.getUrl()
}
zaharovvv_suek_ru
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.
June 7, 2018

Thanks you so much, @Tarun Sapra!

I've just added application name to be defined whether an application name is Confluence:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.RemoteIssueLinkManager
import org.apache.log4j.Level
import org.apache.log4j.Logger

Logger log = Logger.getLogger("com.onresolve")
log.setLevel(Level.INFO)

def issue = ComponentAccessor.issueManager.getIssueObject("<your issue key>")
def RemoteIssueLinkManager remoteIssueLinkManager = ComponentAccessor.getComponent(RemoteIssueLinkManager);
def remoteLInks = remoteIssueLinkManager.getRemoteIssueLinksForIssue(issue)

remoteLInks.each {confl ->
log.debug(confl.applicationName)
}

 

Suggest an answer

Log in or Sign up to answer