I have a web page URL which I want to add as Web Link to Issue(of type bug) in Jira On create
Below code not working (I am using Listener)
import com.atlassian.jira.issue.link.RemoteIssueLinkBuilder
import com.atlassian.jira.issue.link.RemoteIssueLink
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.RemoteIssueLinkManager
if(issue.getIssueTypeObject().getName()=="Bug"){
RemoteIssueLink link = new RemoteIssueLinkBuilder().issueId(issue.getId()).url("http://test.hostname.com/resource.html").title("Test-Link").build();
ComponentAccessor.getComponent(RemoteIssueLinkManager.class).createRemoteIssueLink(link, ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser());
}
Hi @Kiranped ,
Your code seems to be missing the definition of issue, see the bold part before the if, and also you should use getIssueType instead of getIssueTypeObject deprecated in JIRA 7;
import com.atlassian.jira.issue.link.RemoteIssueLinkBuilder
import com.atlassian.jira.issue.link.RemoteIssueLink
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.RemoteIssueLinkManager
def issue = event.issue
if(issue.getIssueType().getName()=="Bug"){
RemoteIssueLink link = new RemoteIssueLinkBuilder().issueId(issue.getId()).url("http://test.hostname.com/resource.html").title("Test-Link").build();
ComponentAccessor.getComponent(RemoteIssueLinkManager.class).createRemoteIssueLink(link, ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser());
}
Also since your listener is attached to Issue created event, you need to confirm in your workflow if the create transition is triggering the Issue created event (check for the last post-function in the create transition)
I've seen some cases that create transition was using Generic Event instead of Issue create, which didn't triggered the Listener.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.