Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Groovy .each iteration unexpected output - multiple log entries Edited

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:
Screen Shot 2020-11-25 at 5.21.13 PM.png

Here is the output from the log on success:Screen Shot 2020-11-25 at 5.12.51 PM.png

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!

1 answer

0 votes

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.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.5.1
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

637 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you