Hello,
I have the following code snippet as part of a scripted listener I am working on to set the assignee on a related issue. I seem to be close but I have unexpected behaviour when the code is successful, failure works as intended.
Case: I have an Epic, with three issues in the epic. One of those issues is type "Billing Request".
issueLinkManager.getOutwardLinks(epicIssue.id).each { issueLink ->
if (issueLink.issueLinkType.name == "Epic-Story Link") {
def linkedIssue = issueLink.destinationObject
if(linkedIssue.issueType.name == "Billing Request"){
def billingRequest = linkedIssue
log.info "Found Billing Request: ${linkedIssue.getKey()}"
if(billingRequest.status.name == "Validation"){
log.info "Billing Request in Validation"
def issueInputParameters = new IssueInputParametersImpl()
issueInputParameters.setAssigneeId(userName)
def updateValidationResult = issueService.validateUpdate(user, billingRequest.id, issueInputParameters)
def issueUpdateResult = issueService.update(user, updateValidationResult, EventDispatchOption.ISSUE_UPDATED, false)
log.info "Assignee set to ${userName}"
}
else log.warn "Assignee not set; Billing Request in status: ${billingRequest.status.name}"
}
}
}
EDIT: Not sure why the formatting is so bad... here's a screenshot of the same code more readable:
Here is the output from the log on success:
Why is log data being posted for the iteration's that failed? Since they are nested within the IF statement, wouldn't this only have one line per success which is exactly one issue in my test case? I don't understand why I would have so many lines in the log on a success. Failure seems to log as expected.
Any insight is appreciated!
Any chance you actually have 2 identical links between those two issues?
Maybe add a line at the top of your "each" block:
log.info "Examining issues link with id=$issueLink.id"
If you have a different id before each of the successes, that should give you a clue.
I do not have identical links.
I will try this and see what the results are when I have time. Thank you for the suggestion.
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.