Jira Expression of the week — Feature Freeze

Jodocus
Jodocus
Jul 29 · 4 min read
Photo by erin mckenna on Unsplash

Here at Jodocus, our development team works in sprints as do many of our clients. We have one particular rule that really has been working well for us: When a sprint nears its end, we disallow starting work on new issues, even though they have been planned for the sprint. We call it a (mini) Feature Freeze.

Today, we’ll look at the validator we implemented to ensure the Feature Freeze. First though, have a look at our workflow:

Our basic workflow

Stories start in Backlog and stay there until we schedule them for a sprint. Once they are scheduled for a sprint, the status changes to “Selected for Development”. However, the transition to “In Progress” (indicating that actual work is starting) is only allowed to happen if a) the Story is part of the current sprint and b) the end of the current sprint is more than three days in the future. If the sprint’s end is closer, we do not want anyone to start new work. To enforce this behaviour, we have created a Jira Expression that checks both conditions, a) and b). We have then created a custom Validator using Cloud Workflows and assigned it to the “Start Working” transition. This expression is our Jira Expression of the week.

Now, this week’s expression is quite a bit longer than the ones you have seen in the first three articles. There are three parts to this week’s expression: First, making sure the issue is in the current sprint. Second, ensuring the current date is more than three days away from the end of the sprint and finally a way to link these two parts together, so that they both must be true for the validator to pass. Let’s break it down and look at the three parts one by one.

The issue must be in an active sprint

Software projects in Jira can be organized into sprints with each issue either being assigned to a sprint or the backlog. Sprints usually happen sequentially, but can in certain circumstances overlap or even happen simultaneously. In Jira Expressions every issue has an attribute sprint that either refers to the sprint the issue is assigned to or contains the value null if the issue has not been assigned to a sprint. Looking at the Jira Expressions reference documentation, we quickly find that sprints have a state attribute which can be either future, active or closed. You can probably guess what they each refer to: ‘future’ is any sprint that has not started yet, closed is any sprint that has already finished and sprints that are currently being worked on are active. So, the first part of our expression comes to:

issue.sprint.state == ‘active’

The sprint’s end date must be further than three days away

To ensure this part, we need to know today’s date, which is rather easy, as a newly created date object always represents today. All we need to get today’s date is:

new Date()

We just saw how to access the state attribute of the issue’s sprint. A sprint also has an endDate attribute, from which we can count backwards three days with minusDays(3). The minusDays(x) function subtracts x days from a date. Naturally, there is also a corresponding plusDays(x) function that adds x days.
As long the newly calculated date is greater than today (ie in the future), we are still far away enough from the end of the sprint to start working on the issue. We can express this like this:

issue.sprint.endDate.minusDays(3) > new Date()

Linking two parts of an expression

By now we have two Expressions that both work perfectly well on their own, but we want to link them up so that we just need one validator. The good news is, that this is pretty easy to do with a logical AND-operator; in Jira Expressions that’s &&. So, linking the two parts simply looks like this:

issue.sprint.state == ‘active’ 
&&
issue.sprint.endDate.minusDays(3) > new Date()

The expressions on the two sides of the && both must be met in order for the whole expression to become true and allow the transition to take place. In plain English: Work on an issue can only be started if the issue is assigned to a sprint that is in the active state (line 1), this sprint’s end date must be at least three days away (line 3) and both conditions must be met (line 2).

Conclusion

And here it is, our Feature Freeze Validator:

Feature Freeze Validator

Next week, we will look at how to aggregate data with Jira Expressions.

Jodocus Blog

Jodocus

Written by

Jodocus

Builder of Jira Cloud Apps :: Atlassian Partner from Germany :: Offering Training, Consulting, and Licenses. https://jodocus.io/

Jodocus Blog

Makers of Jira Cloud Apps :: Atlassian Solution Partner from Germany. This is our blog about Jira Cloud and Atlassian, about Processes and Workflows and how to get things done.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade