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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.Logger
import 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.
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.
Sorry, going back a couple of comments:
If the line
def issue = event.issue
is not working, then it implies that you are not putting the script in a listener.
Listeners provide an event object to them (but you might not be working in the context of something that happens to an issue). If you're in a post-function (which do have a lot in common with listeners) or a condition or validator, there is no event, but you are running within an issue context, so you can just use the issue object directly.
In the second script, it looks like newstring is null because you're setting the fix version to empty - deleting it, not changing it to version 1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've resolved the def issue = issue event. Turns out that the listener console shows an error on that line until you save it.
As far as your 2nd statement, do you mean in the code? Because on the issue I'm just changing the version from Test version 3 to Test version 1.
and is it not finding the linked issues because it doesn't get to that step? I've been working on this for a month now and it doesn't seem that it should be this hard.
thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your screenshot (and returned history string) are saying that you've blanked out the version, not set it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
please see the ticket that you commented on in 2014.
this is what is happening. how do I resolve this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What appears to be happening here is that you're blanking out the version on the issue, not setting it to something else. Your screenshot and history record say that's what is happening.
So I'm stuck on what you are asking now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've attached images show exactly what I'm doing as well as the log below to show how the system is reacting.As you can see from the image, Test Version 1 was already there but that's not reflected in the log.
2020-07-12 22:23:52,967 http-nio-8080-exec-21 INFO Eric.Sebian@JCrew.Com 1343x14033467x1 e1oc2b 165.225.38.249,198.143.38.19,10.200.8.60,10.200.88.9 /secure/AjaxIssueAction.jspa [com.onresolve] *****Issue AWNEP-57 change = [newvalue:32425, field:Fix Version, oldstring:null, newstring:test version 2, id:4509304, fieldtype:jira, oldvalue:null, group:2832821]
[root@ue1latljirasp02 log]#
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.