Hi,
We use JIRA 6.2.7 in our firm. Also we use Script Runner plugin.
We would like to automatically create issues, when specific issue type is created.
We wrote script (triggered by Scriptrunner) which do this.
Problem is, that in 1 of 20 attempts, JIRA doesn't create issue link between parent and subissue. In other 19 attempts, everything is all right.
When I look at history at affected issues where should be link, I see that links there, but issues aren´t actually linked. As you can see in screenshot.
Have someone any idea, where can be problem?
Thanks
bug jira link.png
Ad1) Other side of link is actually same. In history I can see link to bugged issue.
atlasiani2.png
Ad2) Field, Original Value and New Value Jira shows only when first entry is added. In every situaton, if u have few similar entries, Jira shows descriptions only above first of all.
Ad3) I think, that´s also correct. As I said, cca 95% of created issues are fine, only random cca 5% are bugged.
mystery. if youre saying that there is activity stream trace in both issues that are supposed to be linked, then i am pretty sure that the link was actually created and has at least existed. Maybe it actually exists, but is just not being shown for some reason. (i.E. Exception during rendering of Linking Panel on Issue Screen). Anyway, you must try to figure out the condition when the issues get buggy. There must be something special about them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Link was set, but issues aren´t actually linked...
I tried create link between issues by myself and it works.
In activity stream it looks same like before with script. (just link appear)
attlasiani.png
How I said, script create issues and link correctly in 95% of cases.
Only random 5% of created issues is "bugged"
Issue linking is enabled and linking panel is enabled too.
PS: sorry for writing new answers always, but I can´t insert screenshot and code to comment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
realy mysterious that there is actually a trace of the link in activity stream. I cannot imagine that it is possible to create history entry without having created the link first. The link description and linked issues summary must have been coming from somewhere. So, either the link was deleted after it was created somehow, or the link exists but is not being rendered for some reason. can you check the other side of the missing link? What does the history of the other issue say, that should have been linked? Is there also a corresponding entry in activity stream? when a link is created there are history entries created on both linked issues usually.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
one thing that i've noticed. When you create the link manualy, the history entry looks different. When the link was created with the script, you can see "Field", "Original Value" and "New Value". But when you create it manually, you don't see that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also, please check if source and destination issues are in correct order when you create link like this: ComponentAccessor.getIssueLinkManager().createIssueLink(newIssue.getId(),event.getIssue().getId(),linkType,(long)0,event.getUser()); Sure that the new Issue is your source issue for the link?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The script looks good to me. I don't see any potential problems. And you would probably see some Exceptions if there was any. The activity stream of your affected issue clearly shows that the link was set. Are you sure that the link is definetely missing (sometimes)? check that issue linking is enabled. check that the issue linking panel is enabled in plugins menu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can see our script here:
package com.libgroovy; import java.util.HashMap; import java.util.Map; import org.apache.log4j.Logger; import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.event.issue.AbstractIssueEventListener; import com.atlassian.jira.event.issue.IssueEvent; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; class NewIssueCreated extends AbstractIssueEventListener { Logger log = Logger.getLogger("com.onresolve.jira.groovy.NewIssueCreated"); void createTickets(java.util.ArrayList ticketNames, long linkType, IssueEvent event) { def ticketName = ""; def newIssueType; def issueType = 3; ticketNames.each() { ticketName = "${it}"; newIssueType = (ComponentAccessor.getConstantsManager().getAllIssueTypeObjects()).find{it.name=="${ticketName}"}; if (newIssueType) issueType = newIssueType.getId(); // newIssueType = ComponentAccessor.issueTypeSchemeManager.getIssueTypesForProject(event.issue.projectObject).find{it.name=="${ticketName}"} MutableIssue issueObject = ComponentAccessor.getIssueFactory().getIssue(); //issueObject.setProject(ComponentManager.getInstance().getProjectManager().getProject(new Long(10601))); issueObject.setProjectObject(event.getIssue().getProjectObject()); issueObject.setIssueTypeObject(ComponentAccessor.getConstantsManager().getIssueTypeObject("${issueType}")); issueObject.setSummary("${event.issue.getSummary()} - ${ticketName}"); issueObject.setReporter(event.getUser()); //issueObject.setAssignee(event.getUser()); // issueObject.setAssignee(event.issue.getAssignee()); issueObject.setAssignee(null); issueObject.setPriorityId(event.getIssue().getPriorityObject().getId()); issueObject.setDescription("Auto: ${ticketName}"); Map params = new HashMap(); params.put("issue", issueObject); Issue newIssue = ComponentAccessor.getIssueManager().createIssueObject(event.getUser(), params); // ImportUtils.setIndexIssues(true); // ComponentManager.getInstance().getIndexManager().reIndex(newIssue); // ImportUtils.setIndexIssues(false); try { ComponentAccessor.getIssueLinkManager().createIssueLink(newIssue.getId(),event.getIssue().getId(),linkType,(long)0,event.getUser()); //check if the link really exists - sometimes it doesn't work, but no error is raised int linkedIssueCount = ComponentAccessor.getIssueLinkManager().getLinkCollectionOverrideSecurity(newIssue).getAllIssues().size(); log.info("Issue "+newIssue.getKey()+" linked issue count: " + linkedIssueCount); if (linkedIssueCount > 0) log.info("Issue "+newIssue.getKey()+": a link to issue "+event.getIssue().getKey()+" created."); } catch (Exception e) { log.error("Issue "+newIssue.getKey()+": error when creating a link to issue "+event.getIssue().getKey()+".", e); } } } @Override void workflowEvent(IssueEvent event) { log.info("NewIssueCreated-Copy2.groovy: Workflow event fired for issue " + event.getIssue().getKey()); return; def projectKey = event.getIssue().getProjectObject().getKey(); def ticketNames = []; def ticketNames2 = []; def linkType = 10303; def linkType2 = 10303; if((event.issue.getIssueTypeObject().getName()).equals("FR")){ ticketNames = ["Solution Design", "Test Scenario", "Development","Parametrization","Documentation", "Automated Test","Test"]; linkType = 10601; ticketNames2 = ["Bug Fixing"]; linkType2 = 10502; }else if((event.issue.getIssueTypeObject().getName()).equals("BREQ") ) { ticketNames = ["Bug Fixing"]; linkType = 10501; }else if((event.issue.getIssueTypeObject().getName()).equals("Simple Enhancement")) { ticketNames = ["Bug Fixing"]; linkType = 10700; } createTickets(ticketNames, (long) linkType, event); createTickets(ticketNames2, (long) linkType2, event); } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
such behaviour is often related to wrong list or array dimensions. let us see the code of the script
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
have you tried reindexing?
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.