Validate a Confluence Link During Transition

Tej March 9, 2017

How to validate a link (a confluence link, Wiki Page) to transition an issue.

[I mean I just to check a wiki page, issue should not go to next state without a confluence link]

any chance by using scriptRunner

Thanks 

Dave

3 answers

4 votes
T March 15, 2017
import com.atlassian.applinks.api.ApplicationLinkService
import com.atlassian.applinks.api.application.confluence.ConfluenceApplicationType
import com.atlassian.jira.bc.issue.link.RemoteIssueLinkService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.RemoteIssueLink
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Logger
 
static boolean hasAnyRemoteConfluenceLink(ApplicationUser user, Issue issue, Logger log = null) {
    def applicationLinkService = ComponentAccessor.getComponent(ApplicationLinkService)
    def remoteIssueLinkService = ComponentAccessor.getComponent(RemoteIssueLinkService)
    def conf_link = applicationLinkService.getApplicationLinks(ConfluenceApplicationType)?.first()
    if (!conf_link) {
        log?.error "No confluence application link found."
        return false
    }
    return remoteIssueLinkService.getRemoteIssueLinksForIssue(user, issue)?.remoteIssueLinks?.any{it.applicationType == RemoteIssueLink.APPLICATION_TYPE_CONFLUENCE}
}
 
hasAnyRemoteConfluenceLink(ComponentAccessor.jiraAuthenticationContext?.loggedInUser, issue)
0 votes
Tej March 13, 2017

I want to verify that at least one confluence page is linked.

wiki page link.png

Mamta Kalwani March 11, 2020

Hi Tej, did you manage to do this? Would be grateful if you could share an updated script !

 

Thanks :)

0 votes
Niclas Sandstroem
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.
March 12, 2017

What exactly do you want to validate? Response from Confluence or that it's a link?

Suggest an answer

Log in or Sign up to answer