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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,461,953
Community Members
 
Community Events
176
Community Groups

Prevent a blocked issue from transitioning until the blocker is 'Done'

We're looking to prevent an assigned user from starting work on a blocked issue until the issue blocking it is completed.  Ideally, we would want assignee A to complete the issue, and once the status is "Done/Resolved/Closed", this would notify the user of the blocked issue that they can begin work.

We're installed ScriptRunner as we're planning to use it for other things, but I can't seem to get my head around how to accomplish this in JIRA Cloud.

Any suggestions or insight?

1 answer

Hi Kyle,

The short answer is that you can create a Script Post-Function on that Done/Resolved/Closed transition that looks at the issue links of the issue being completed, and sends an issue notification to the assignee of those issues.

Have a look at our documentation for more details and code examples. Do ask if you need a hand with the code.

Thanks,
Jon

Hey Jon,

I appreciate the insight.  I'm still getting acclimated to JIRA and ScriptRunner, so any assistance would be appreciated.  I believe the solution you've outlined would work quite well, however I am a bit confused on how to execute that into code for ScriptRunner.  I have a basic understanding of the Script Post-Function, and what needs to be checked and executed, just not sure how to write that.

I assume a condition that states "if issue being transitioned to Done/Resolved/Closed has a linked issue of blocked" then "send notification".  Just not sure how to write that for ScriptRunner.

Any assistance is appreciated.

Thanks.

 

 

 

In your Condition you'll need code like this:

issue.fields.issuelinks.any { link ->
link.type.name == 'Blocks'
}

And in your Code you'll need code like this:

def blocks = issue.fields.issuelinks.findAll { link ->
link.type.name == 'Blocks'
}

blocks.each { link ->
// NB - If the issue that was just completed is the
// one being blocked then the link will have an
// inwardIssue property instead
def thisIssueBlocks = link.outwardIssue != null
if (thisIssueBlocks) {
def resp = post("${link.outwardIssue.self}/notify")
.header('Content-Type', 'application/json')
.body([
subject: "You can start work now",
textBody: "${issue.key} has been completed, please get cracking!",
htmlBody: "<p>${issue.key} has been completed, please get cracking!</p>",
to: [
assignee: true,
reporter: false,
watchers: false,
voters: false
]
])
.asString()
// NB - please note that you can't send notifications
// to yourself, so if the assignee is the same as the
// user executing the post function then response code
// will be 400
assert resp.status == 204
}
}

Link this:

Screen Shot 2017-07-18 at 17.30.25.png 

Hey @Jon Bevan [Adaptavist],

This solutions worked perfectly, so thank you for that!  Im curious to know if I could append to this a method to remove the block when the issue is transitioned to Closed.  This would help drive a more accurate dashboard for our team members on what they need and/or can work on now as opposed to things they're waiting on, if that makes sense.  So upon the "Close" transition, the block would be removed, and they're "To Do" list would now show the next task as being available to work on.

Yes you can definitely do that - the REST API for issue links permits you to remove them.

You can access details of the transition itself using the `transitionInput` variable as documented here: http://scriptrunner-docs.connect.adaptavist.com/jiracloud/post-functions.html#_bindings

@Jon Bevan [Adaptavist] Do you know if there is a way to do this without script runner (i.e. prevent issues from being started until other issue is marked as done)?  

I don't think that Jira has anything out-of-the-box that will achieve this for you.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events