Hello dear Community,
currently I have following requirements:
As a User, I want that all my issues automatically get a parent/child relationship when I link two tickets together (and vice versa, but this requirements is negligible for now), so that my child issues always have the Epic Link.
AC01: The Script should only run if an Epic is linked to a child (Story, Feature)
AC02: The Script Listener should run as soon as I´m creating a link between to tickets
AC03: The Script Listener should run as soon as I´m creating a Parent/Child relationship
AC04: The Script should run in a "loop" so that all linked issues get the Epic Link (Parent/Child relationship). I already have a script which works as I want, but it only uses the first linked issue.
I wrote with the help of a colleague this script and let it run in the script console. It works perfectly, except of the fact, that it only uses the first linked issue in the epic and not all linked issues...
import groovy.json.JsonOutput
def sec = get("/rest/api/2/issue/AK-3")
.header("Content-Type", "application/json")
.asObject(Map)
.body
sec
def tick = sec.fields.issuelinks.inwardIssue[0].key
def returnData = [
fields: [
"parent": sec
]
]
def updatedIssue = put("/rest/api/2/issue/${tick}")
.header("Content-Type", "application/json")
.body(JsonOutput.toJson(returnData))
.asString()
updatedIssue
I tried to recreate this script in the Script Listener, but unfortunately it doesn't work:
import groovy.json.JsonOutput
def source = issueLink.sourceIssueId
def dest = issueLink.destinationIssueId
def issue = get("/rest/api/2/issue/${source}")
.header("Content-Type", "application/json")
.asObject(Map)
.body
def returnData = [
fields: [
"parent": issue
]
]
def updatedIssue = put("/rest/api/2/issue/${dest}")
.header("Content-Type", "application/json")
.body(JsonOutput.toJson(returnData))
.asString()
updatedIssue
I would love to hear your suggestions and thanks in advance for helping me out.
Best regards,
Tamir