Cookbook

A cookbook filled with real-life recipes of what is possible with Cloud Workflows.

Issue must be in the current sprint

Problem

When working in agile projects using sprints, you might want to enforce discipline by making sure that only issues which are part of the current sprint can be set to a certain status such as "In Progress".

Solution

You can do this either with a condition or a validator. In either case, add a custom condition (validator) to those transitions you want to control and use the following Jira expression:

1 issue.sprint.state == 'active'

Bugs need an explanation

Problem

Fixing bugs is great, but it's only half the work. We also want to be sure that a bug will not be repeated. Hence, we want developers to add a short explanation in form of a comment before they can close a bug.

Solution

You’ll want to use a validator here, as it is typical for the comment to be entered during the transition. Add a custom validator to the transition that resolves a bug, using the following Jira Expression to ensure that the current user has added a comment of at least 100 characters in length.

1 2 3 4 issue.comments   .filter(c => c.author.accountId == user.accountId)   .filter(c => c.body.plainText.length > 100)   .length > 0

Ensure all the specs and tests have been written

Problem

Whenever you are about to start working on a story you’ll want to make sure that all specs and a test plan are complete and available . Let's assume that both, specs and test plans, each have certain issue type.

Solution

You can do this either with a condition or a validator. In either case, add a custom condition (validator) to the transition that starts work on a story and use the following Jira expression:

1 2 3 4 5 6 issue.links   .filter(li => li.linkedIssue.issueType.name == 'Spec'              && li.linkedIssue.status.name != 'New').length > 0 && issue.links   .filter(li => li.linkedIssue.issueType.name == 'Test Plan'              && li.linkedIssue.status.name != 'New').length > 0

Make sure all sub-tasks have been closed

Problem

Jira Cloud conveniently asks you whether to close an issue once all sub-tasks have been closed. However, it will allow you to close an issue, even though it has open sub-tasks.

Solution

Conditions work best here, so add a custom condition to the transition that closes your issue and use the following Jira Expression:

1 2 3 issue.subtasks   .filter(s => s.status.name != 'Done')   .length == 0

Purchase Approval during On-Boarding

Problem

Imagine you track all purchases that need to be done for a new-hire as individual sub-tasks to an on-boarding issue. While you want the team to just go ahead and buy what they believe is needed most of the time, once a certain overall threshold (say $100.000) is reached, you’ll want the hiring manager to approve further costs. The sub-tasks have a custom field that hold the price of each individual purchase, while the on-boarding issue itself holds the hiring manager in another custom field.

Solution

You can do this either with a condition or a validator. In either case, add a custom condition (validator) to the transition that starts work on a story and use the following Jira expression, assuming that customfield_10044 is the price and customfield_10058 is the hiring manager:

1 2 3 4 5 issue.subtasks   .map(n => n.customfield_10045)   .reduce( (a, b) => a + b,0) < 10000 || user.accountId ==   ( issue.customfield_10058 ? issue.customfield_10058.accountId : null )