I am slowly learning groovy and scriptrunner. I Need help copying a fix version field value to linked issues using scriptrunner listener. I found solutions using post function scripts but nothing for the listener. I have done various searches on the web as well as searched the Adaptavist library but have found nothing. Their support Please advise
This should give you most of what you need: https://library.adaptavist.com/entity/update-a-field-across-all-the-linked-issues-itsm
Hi Nic. is there a service that your company provides that I can purchase to walk me thru creating a particular script? Maybe someone in the company who'd be willing to freelance for a fee. I'd be paying personally so it couldn't be exorbitant. I'm great at managing jira projects but coding related tasks go over my head every time. I'm better at learning thru real world applications. Hope that makes sense.
Also, when i plug in the code from the link that you suggest above into a custom listener, it's riddled with errors. It's hard to start to figure out how to tweak it when it doesnt seem to be a working listener script. See image.
Ok, Nic. Based on your advice I hunted and pecked and cobbled together a script that seems SHOULD work. Unfortunately, it doesn't. Referencing the script that you suggested and a host of others I got the following:
import com.atlassian.jira.issue.MutableIssue;import com.atlassian.jira.issue.link.IssueLink;import com.atlassian.jira.issue.link.IssueLinkManager;import com.atlassian.jira.component.ComponentAccessor;import com.atlassian.jira.event.type.EventDispatchOption;import org.apache.log4j.Loggerimport org.apache.log4j.Level
def log = Logger.getLogger("com.onresolve")log.setLevel(Level.INFO)
def issue = event.issue
if(issue.issueType.name == "Epic") {log.info "*****Issue $issue is a EPIC"def projectKey = issue.projectObject.key;
def change = event.getChangeLog().getRelated("ChildChangeItem").find {it.field == "Fix Version"}log.info "*****Issue $issue change = $change"//def change_issue = issue?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Fix Version/s"}//logs.info "*****change_issue = $change_issue"def issueLinkManager = ComponentAccessor.issueLinkManager;def issueManager = ComponentAccessor.issueManager;
if(change) {issueLinkManager.getOutwardLinks(issue.getId()).each {IssueLink issueLink ->if (issueLink.getIssueLinkType().getName() == "Epic-Story Link") {log.info "*****Issue $issue is a Epic-story link"def destinationIssue = (MutableIssue)issueLink.getDestinationObject();if(destinationIssue.projectObject.key.equals(projectKey)) {
destinationIssue.setFixVersions(issue.fixVersions)log.info "*****setting up fixVersions $issue.fixVersions"issueManager.updateIssue(event.getUser(), destinationIssue, EventDispatchOption.DO_NOT_DISPATCH, false)}}}}}
i added logging info at different points to determine how far it's getting. So in the logs I see that it gets past identifying that the issue is an EPIC:
2020-07-06 23:32:17,159 http-nio-8080-exec-50 INFO Eric.Sebian@JCrew.Com 1412x6763879x1 ve7ttp 69.20.50.84,198.143.37.19,10.200.8.60,10.200.88.9 /secure/AjaxIssueAction.jspa [com.onresolve] *****Issue AWNEP-54 is a EPIC
and then, after I define the change the logs show that the fix version change is identified but the changelog is missing information:
2020-07-06 23:32:17,161 http-nio-8080-exec-50 INFO Eric.Sebian@JCrew.Com 1412x6763879x1 ve7ttp 69.20.50.84,198.143.37.19,10.200.8.60,10.200.88.9 /secure/AjaxIssueAction.jspa [com.onresolve] *****Issue AWNEP-54 change = [newvalue:null, field:Fix Version, oldstring:test version 3, newstring:null, id:4498125, fieldtype:jira, oldvalue:32426, group:2825840]
new string continually comes back Null. this should not be because I changed it from test version 3 to test version 1.
It also never finds the linked issue connectedto update. See image.
Please advise.
It looks like you're new here. Sign in or register to get started.