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

This widget could not be displayed.

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

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Jul 25, 2018 in Marketplace Apps

Jira Cloud and Bitbucket Cloud Integration with Microsoft Teams

One of the newest products in the Microsoft family - Microsoft Teams,  is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...

733 views 0 3
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you