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

Kyle Lamberson June 29, 2017

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

2 votes
Jon Bevan _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2017

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

Kyle Lamberson July 17, 2017

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.

 

 

 

Jon Bevan _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2017

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 

Kyle Lamberson August 23, 2017

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.

Jon Bevan _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 29, 2017

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

Ashley Leger March 20, 2022

@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)?  

Jon Bevan _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2022

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
AUG Leaders

Atlassian Community Events