Creating common transitions in workflows

Configuring workflows can be a painful thing, especially when there are similar transitions used in 10 different places and they get changed every now and then. The change might be the simplest thing possible, such as editing just the name of the transition, but we still end up modifying it in 10 places.

This is where OSWorkflow's common actions come to our rescue. These are transitions that can be shared across the various statuses. The most important thing to remember here is that the target status of the common transitions will be the same, and they share the same workflow elements like triggers, conditions, validators, post functions, and even transition properties.

The default workflows in JIRA come with some common transitions. For example, the Software Simplified Workflow comes with common transitions like In Progress and Done. If you need to modify one of these transitions, you need to modify it only once and the change will be made everywhere. If we modify the Done transition name to Done Modified, it changes everywhere, as shown below:

Creating common transitions in workflows

In this recipe, let us look at adding a new common transition.

How to do it...

The first step in adding a common transition is to create a workflow transition, with all the required elements in it. Let us assume that we have added a new Rejected state in our workflow and created a transition from In Progress to Rejected state, named Reject.

If we need to add the same transition, that is, to Rejected state from another source status like To Do, we can do this by creating a common transition.

The following is the step-by-step procedure:

  1. Create the common transition, Reject, as explained previously.
  2. Create a transition from the new source status, To Do in this case, using the workflow Diagram view.
  3. In the Add Transition pop up window, select the Reuse a transition tab.
  4. Select the From Status, To Do, and the To Status, Rejected. Depending on our selection, the Transition to reuse box will be populated with available transitions that we can reuse, as shown here:
    How to do it...
  5. Click Add.

With that, the common transition is created! You can use the same transition again by following steps 2-4.

How it works...

JIRA workflows fundamentally use OpenSymphony's OSWorkflow, as we saw in Chapter 2, Understanding Plugin Framework. OSWorkflow gives us the flexibility to add common actions by modifying the workflow XML. JIRA provides the icing on the cake by providing a powerful HTML editor that can be used to create these common transitions very easily.

The following screenshot is how the updated workflow looks in the Text view:

How it works...

As you can see, the new transition has the same ID, 41, from both To Do and In Progress states. We can modify any attribute on this transition, and it will be reflected in all the places where the transition is used.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.172.195