So, let's take a look at how to create and set up a new workflow in JIRA. To create a new workflow, all you need is a name and description:
The newly created workflow will only contain the default create and open status, so you will need to configure it by adding new statuses and transitions to make it useful. Let's start with adding new statuses to the workflow using the following steps:
Now that the statuses are added to the workflow, they need to be linked with transitions so that issues can move from one status to the next. There are two ways to create a transition:
Both options will bring up the Add Transition dialog, as shown in the following screenshot:
From the preceding screenshot, you can choose to either create a new transition with the New Transition tab or use an existing transition with the Reuse a transition tab.
When creating a new transition, you will need to configure the following:
Close Issue
.
If you want to reuse an existing transition, simply click on the Reuse a transition tab, the From and To statuses, and the Transition to reuse, as shown in the following screenshot:
You might be wondering when you should create a new transition and when you should reuse an existing transition. The big difference between the two is that when you reuse a transition, all instances of the reused transition, also known as common transition, will share the same set of configurations, such as conditions and validators. Also, any changes made to the transition will be applied to all instances. A good use case for this is when you need to have multiple transitions with the same name and setup, such as Close Issue
; instead of creating separate transitions each time, you can create one transition and reuse it whenever you need a transition to close an issue. Later on, if you need to add a new validator to the transition to validate additional user input, you will only need to make the change once, rather than multiple times for each Close Issue
transition.
Another good practice to keep in mind is to not have a dead end state in your workflow, for example, allowing closed issues to be reopened. This will prevent users from accidentally closing an issue and not being able to correct the mistake.
One thing people often overlook is, you can change the status an issue is transitioned to when it is first created. By default, an issue is placed in the Open status as soon as it is created. While this makes sense for most cases, you can actually change that. For example, you might want all your issues to be in a Waiting status and transition to Open only after someone has reviewed it. You can also make changes to the default Create Issue transition. By doing so, you can influence the issue creation process. For example, you can add a validator to it to add additional checking before an issue is allowed to be created, or add a post function to perform additional tasks as soon as an issue is created.
Now that we have seen how to add new statuses and transitions to a workflow, let's look at adding triggers, conditions, validators, and post functions to a transition.
You can only add triggers to transitions if JIRA is integrated with at least one of the supported development tools. To add triggers, perform the following steps:
New transitions do not have any conditions by default. This means that anyone who has access to the issue will be able to execute the transition. JIRA allows you to add any number of conditions to the transition:
Newly added conditions are appended to the end of the existing list of conditions, creating a condition group. By default, when there is more than one condition, logical AND
is used to group the conditions. This means that all conditions must pass for the entire condition group to pass. If one condition fails, the entire group fails, and the user will not be able to execute the transition. You can switch to use the logical OR
condition, which means only one of the conditions in the group needs to pass for the entire group to pass. This is a very useful feature as it allows you to combine multiple conditions to form a more complex logical unit.
For example, the User Is In Group condition lets you specify a single group, but with the AND
operator, you can add multiple User Is In Group conditions to ensure that the user must exist in all the specific groups to be able to execute the transition. If you use the OR
operator, then the user will only need to belong to one of the listed groups. The only restriction to this is that you cannot use both operators for the same condition group.
Like conditions, transitions, by default, do not have any validators associated. This means that transitions are completed as soon as they are executed. You can add validators to transitions to make sure that executions are only allowed to be complete when certain criteria are met. Use the following steps to add a validator to a transition:
Similar to conditions, when there are multiple validators added to a transition, they form a validator group. Unlike conditions, you can only use the logical AND
condition for the group. This means that in order to complete a transition, every validator added to the transition must pass its validation criteria. Transitions cannot selectively pass validations using the logical OR
.
The following screenshot shows a validator (the Field required validator from JIRA Suite Utilities, refer to the Extending workflow with workflow add-ons section) being placed on the transition, which validates whether the user has entered a value for the Resolution Details field:
Transitions, by default, are created with several post functions. These post functions provide key services to JIRA's internal operations, so they cannot be deleted from the transition. These post functions perform the following:
As you can see, these post functions provide some of the basic functions such as updating a search index and setting an issue's status after transition execution, which are essential in JIRA. Therefore, instead of letting users manually add them in and risk the possibility of leaving one or more out, JIRA adds them for you automatically when you create a new transition:
Just like conditions and validators, multiple post functions form a post function group in a transition. After a transition is executed, each post function in the group is executed sequentially as it appears in the list, from top to bottom. If any post function in the group encounters an error during processing, you will receive an error, and the remaining post functions will not be executed.
Since post functions are executed sequentially and some of them possess the ability to modify values and perform other tasks, often, their sequence of execution becomes very important. For example, if you have a post function that changes the issue's assignee to the current user and another post function that updates an issue field's value with the issue's assignee, obviously the update assignee post function needs to occur first, so you need to make sure that it is above the other post function.
You can move the position of post functions up and down along the list by clicking on the Move Up and Move Down links. Note that not all post functions can be repositioned.