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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't think that Jira has anything out-of-the-box that will achieve this for you.
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.