Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


On this page

circle
UI Text Box
borderColor#006275
sizemedium
Panel
Table of Contents
exclude(On this page).*
style
type
flat
separatorpipe

What are Jira expressions?

info

The Jira expression parsing mode, unlike the General mode and the Logical mode, is based on a 

Panel
borderColor#006275

Image Removed

Jira expressions look and feel like regular parser expressions provided by JWT for Jira Cloud but are based on domain-specific language designed and provided by Atlassian with Jira in mind, evaluated on the Jira Cloud side, not JWT.

They It can be used to evaluate custom code in the context of Jira entitiesexpressions. Jira expressions follow JavaScript syntax and can be thought as a JavaScript dialect. See the introduction section from the official documentation here.  


UI Text Box
typenote

(warning)JWT for Jira Cloud only uses the features provided by Atlassian which cannot be modified by JWT for Jira Cloud!



Where are Jira expressions used in JWT for Jira Cloud?

JWT Jira expressions can be used in every context. The Jira expression mode is available in all post functions provided by Jira Workflow Toolbox for Jira Cloud supports the usage of Jira expressions within its Jira as well as in the Jira expression condition and Jira expression validator. 

In order to illustrate with a simple example, the following Jira expression would ensure that an issue is currently assigned to a Jira user.

Code Block
linenumberstrue
issue.assignee != null


What is the difference to

parser

JWT expressions?

While they might look quite same, it is important to know that Jira expressions and the JWT for Jira Cloud parser expressions have  have nothing in common in the background.

The parser expression equivalent The equivalent to our former example, using JWT expression field codes would read:

Code Block
linenumberstrue
%{issue.assignee} != null

Apparently, one of the main differences to Jira expressions is the way fields are referenced: in parser expressions, field values can be referenced by a slightly different set of field codes that are always led by a percentage sign, written between curly brackets, e.g. %{issue.description}the field codes are referenced.

UI Text Boxpanel
borderColor#006275
typetip

Image RemovedRule of thumb!

If you spot %{...} the syntax refers to parser expressions- otherwise you are dealing with Jira expressions.is being used in a JWT expression (either the General mode or the Logical mode). If the { sign is missing you are likely looking at Jira expressions written in the Jira expression mode.

Another major difference is that you can write your own functions (so-called Arrow functions) in Jira expressions and use complex objects.

Image Added Example expressions

Jira expressionDescription


Code Block
linenumberstrue
issue.issueType.name == "Story"


This example makes sure that the current issue type is a "Story".


Code Block
linenumberstrue
issue.subtasks.map(s =>  s.key)


This example returns the keys of all sub-tasks of the current issue as a list:

PU-87,PU-98


Code Block
linenumberstrue
issue.subtasks.reduce((result, issue) => 
            result.set(
                issue.status.name, 
                (result[issue.status.name] || 0) + 1), 
            new Map())


This example counts sub-tasks of the current issue by their status name and returns the result as an object:

{
   "To Do": 1,
   "In Progress": 3
}


UI Expand
titleAdditional examples


UI Expand
titleField codes


Jira expressionDescription


Code Block
linenumberstrue
issue.priority.name == "Medium"


Issue's priority must be "Medium".


Code Block
linenumberstrue
issue.issueType.name.match('^(Bug|Task)$') != null


Issue type must be "Bug" or "Task" (using a regular expression).


Code Block
linenumberstrue
issue.labels.includes("Support")


Check if one of the issue's labels is "Support"



UI Expand
titleNumbers and dates


UI Text Box
borderColor#006275
typetip

Counting elements

You can count elements by adding .length


Jira expressionDescription


Code Block
linenumberstrue
issue.description.plainText.length >= 100


Issue's description must be at least 100 characters in length.


Code Block
linenumberstrue
issue.comments.length >= 5


Issue must have at least 5 comments.


Code Block
linenumberstrue
new Date().getDay() != 1


The current day must not be Monday.

(warning)  (see JavaScript reference for getDay())



UI Expand
titleLists


Jira expressionDescription


Code Block
linenumberstrue
issue.subtasks[0].key


Accessing a specific element of a list: Getting the key of the first sub-task


Code Block
linenumberstrue
issue.subtasks.length


Returns the number of the sub-tasks.


Code Block
linenumberstrue
issue.subtasks.map(s => s.status.name)


Getting a list of the status names of the issue's sub-tasks using the function map


Code Block
linenumberstrue
issue.comments.some(com => com.body.plainText.match('([A-Z][A-Z0-9]+)-\d+') != null)


Issue must have at least one comment containing an issue key (using a regular expression).


Code Block
linenumberstrue
issue.subtasks.some(sub => sub.components.some(comp => (comp.name == "QA")))


Issue must have at least one sub-task with the component "QA" set.


Code Block
linenumberstrue
issue.subtasks
.every(sub => sub.comments
.some(com => com.body.plainText.match('([A-Z][A-Z0-9]+)-\d+') != null))


Every sub-task of the issue must have at least one comment containing an issue key (using a regular expression).


Code Block
linenumberstrue
issue.comments
.map(c => c.body.plainText)
.filter(text => text.length > 99)
.length > 0


Issue must have at least one comment with at least 100 characters.


Code Block
linenumberstrue
issue.links
.filter(link => link.type.name == "Blocks"  )
.length == 0


The issue must not have a link of type Blocks.


Code Block
linenumberstrue
issue.links
.filter(link => link.linkedIssue.status.name == "Done")
.length == issue.links.length


All linked issues must be in the status 

Status
subtletrue
colourGreen
titledone


Code Block
linenumberstrue
issue.links
.filter(link => link.linkedIssue.issueType.name == "Bug")
.every(link => link.linkedIssue.resolution != null)


All linked bugs must be resolved.




Why do I need both?

Right now, Jira expressions are the only officially supported way to formulate custom conditions or validators in Jira Cloud.

Being the "brain" of Jira Workflow Toolbox for Server and Data Center, its JWT expression editor and the underlying expression parser has  have evolved from a small set of handy functions to a comprehensive list and a fundamental part of this app over the years.

Therefore it was only obvious to make this core functionality available for Jira Cloud as well.

As in the Server and Data Center version, it is widely usedJWT for Jira Cloud thus provides two different, powerful means to work with Jira content. In many cases, the functionality is overlapping, e.g. to compose texts using when it comes to certain field codes or to extend post functions by conditional executions using logical expressions.and functions. Furthermore they complement each other: For instance, the JWT expression parser provides a function for getting issues from a JQL query (issuesFromJQL), which is not provided out of the box by Jira expressions. On the other hand, with Jira expressions you are able to define own functions, which requires basic scripting knowledge, and work with more complex data types. 

Choose the appropriate parsing mode depending on your needs and programming skills!

UI Text Box
borderColor#006275
typenote

You cannot mix the different modes in a single expression!


Where do I start?

To ensure that Familiarize yourself with the Jira expression mode. Once you have a quick and easy entry into the world of Jira expressions, we have prepared a comprehensive list of use cases and Jira expression examplesgeneral overview make sure to check out the various use cases  we have prepared for you.

To deep-dive into Jira expressions we suggest reading up on the additional information we have prepared for you:children

What else should I know?

Jira expressions follow certain constraints with regard to the evaluation of those expressions (see the official documentation).

While the limits should be high enough not to interfere with any intended usage, it's important to realize that they do exist:

  • The Expression length is limited to 1,000 characters or 100 syntactic elements.
  • Expressions don't do not support logging or custom error messages. Any non-boolean value will be considered as false false.
  • Expression Expressions can execute a maximum of 10 so-called "expensive" operations, i.e. those that load additional data, such as entity properties, comments, or custom fields, e.g.
    Given an expression to check whether every sub-task has at least one comment containing an issue key, will fail if this issue has more than 10 sub-tasks.

Expression


Code Block
linenumberstrue
issue.subtasks.every(sub => sub.comments.some(com => com.body.plainText.match('([A-Z][A-Z0-9]+)-\d+') != null))
Error message

Image Modified

Need additional resources?

The best way would be to start with the official documentation:



Excerpt Include
DECADIS:Contact support
DECADIS:Contact support
nopaneltrue


Page properties
hiddentrue


Short descriptionLanguage designed by Atlassian to work with Jira entities. 
Supported elements
Output

Status
subtletrue
titleMultiple