ScriptRunner for Jira Cloud Logo

Getting Started

JIRA Extension Points

Releases

If you are familiar with JQL Functions from JIRA Server then some of the concepts here are a little different.

Note

It is not possible in Jira Cloud for an add-on to alter the results of a JQL search either during or after a search is being performed.

ScriptRunner for Jira Cloud augments each issue in your Jira instance with some additional metadata and provides a number of JQL keywords that you can use within your JQL queries to access this metadata. This metadata is stored within your Jira instance.

The 'Issue Updated' field on your issues is NOT affected by the metadata that we store against each issue.

See ScriptRunner Enhanced Search for more powerful search functionality provided by ScriptRunner for Jira Cloud.

Getting Started with JQL Keywords

Note

The metadata that we store against each issue is automatically updated asynchronously whenever an issue is updated. This means that your search results may be out-of-date for a second or two after you edit an issue.

When ScriptRunner for Jira Cloud is installed, or when you want to opt into this feature, an administrator must perform an initial synchronization. Although an administrator initiates the synchronization process, issues are accessed as the ScriptRunner Add-on user.

You can do the initial synchronization on the JQL Keywords Sync page found in the Add-ons Administration section of Jira:

JQL Keywords Sync page

If you close this page while the sync is in progress, it will stop.

Syncing can be resumed at a later date by visiting this page and clicking on the Sync All Issues button. Search results for queries that use these keywords will be incorrect until an initial sync has been completed.

Here is a list of the metadata that we store against each issue:

  • a list of the link types (e.g. Blocks) for linked issues

  • the number of issue links

  • a list of link names (e.g. "is cloned by") for linked issues

  • number of attachments on the issue

  • list of file extensions from attachments

  • the date on which the first attachment was added to the issue

  • date on which the last (most recent) attachment was added to the issue

  • list of username that added attachments to the issue

  • number of subtasks of the issue

  • list of project roles that worklogs were restricted to

  • list of user groups that worklogs were restricted to

  • number of comments on the issue

  • date of the first comment on the issue

  • date of the last (most recent) comment on the issue

  • list of all dates on which comments were added to the issue

  • list of usernames that have added comments to the issue

  • list of project roles that comments have been restricted to

  • list of user groups that comments have been restricted to

  • the username of the person who last (most recent) made a comment on the issue

  • the project role that the last (most recent) comment was restricted to

  • the user group that the last (most recent) comment was restricted to

Permissions

The ScriptRunner Add-on user can only see comments and worklogs from the following groups:

  • jira-code-users

  • jira-servicedesk-users

  • jira-software-users

Search results will be incorrect if the ScriptRunner Add-on user does not have permission to:

  • View and edit all issues (edit permission is required to store the additional metadata).

  • View all comments, including those restricted to a particular group/role.

  • View all worklogs, including those restricted to a particular group/role.

If worklogs and comments are restricted to a role, ensure the role is assigned to the group the ScriptRunner Add-on user belongs to under Project Settings.

JQL Functions

As mentioned at the top of this page, it is not possible to integrate directly into the standard search functionality that Jira Cloud provides.

The ScriptRunner Enhanced Search functionality provides the ability to run advanced JQL functions in your Jira filters in a similar way to ScriptRunner for Jira Server.

JQL Keywords

Each keyword here has an explanation and an example. See the comparison table below for a direct comparison with ScriptRunner for JIRA Server.

Note

These JQL keywords will not work until an initial metadata synchronization has been performed. See the getting started section above.

These JQL Keywords can be used in the Issue Search screen when searching in Advanced mode. Here’s an example of using the numberOfComments JQL Keyword.

JQL Keywords in Issue Search screen

Linked Issues

This keyword is used to retrieve issues that have a certain number of issue links.

status = Open AND numberOfLinks = 3

We can use numeric comparison operators like >, <, !=, <= and >= as well as =.

numberOfLinks > 5 AND numberOfLinks <= 10

issueLinkType

This alias can be used to search for issues based on the type of issue links that they have. The link type is the name that describes the link, regardless of its direction e.g. Blocks, Cloners, Duplicate.

project = SALES AND issueLinkType = 'Blocks'

We can also use the JQL keyword in to search for issues that have any of the specified link types:

assignee = currentUser() AND issueLinkType in ('Blocks', 'Duplicate')

The JQL operators != and not in also work with this keyword.

This keyword can be used to search for issues that have links in a particular direction. This keyword can be compared against a link name e.g. "is blocked by", "duplicates", "relates to"

type = Improvement AND hasLinks = "relates to"

In the same way as issueLinkTypes, you can use the operators: =, !=, in and not in

Attachments

numberOfAttachments

This keyword can be used to find issues that have a certain number of file attachments.

status = Closed AND numberOfAttachments > 3

This keyword can be used with the numeric comparison operators.

attachmentType

This keyword can be used to search for issues that have a particular file type attached to them. File types are determined by the file extension e.g. a file called screenshot.png has a file type of 'png'

numberOfAttachments > 0 AND attachmentType = 'jpg'
issuetype = Invoice AND attachmentType in ('pdf', 'docx', 'xls')

This keyword can use the =, !=, in and not in operators.

firstAttachmentDate

The firstAttachmentDate keyword can be used to find issues based on the date that the first attachment was added:

project = STORAGE AND firstAttachmentDate < now()
project = STORAGE AND firstAttachmentDate >= '2016-04-01'
project = STORAGE AND firstAttachmentDate = '2000-01-01'

As you can see from the first example, we can use relative date functions that come built-in to JQL. We can also use the regular numeric comparison operators.

lastAttachmentDate

The lastAttachmentDate keyword can be used to find issues based on the date that the most recent attachment was added:

project = STORAGE AND lastAttachmentDate > startOfMonth()

In the same way as firstAttachmentDate, this keyword can use the numeric comparison operators and the relative date JQL functions.

fileAttachedBy

This keyword can be used to find issues that have a file attached by a particular user. You must use the username of the user you are interested in.

reporter = currentUser() AND fileAttachedBy = "jbloggs"

This keyword can also be compared using the !=, in and not in operators.

Subtasks

numberOfSubtasks

The numberOfSubtasks keyword can be used to search for issues with a certain number of subtasks.

issuetype = Task AND numberOfSubtasks > 10

This keyword can also use the numeric comparison operators.

Worklogs

Tip
Check the ScriptRunner Add-on Permissions before using these JQL aliases.

worklogVisibleRole

This keyword can be used to find issues that have time logged against them that is restricted so it is only visible to other users in a specific project role.

timespent > 8h AND worklogVisibleRole = 'Project Administrator'

This keyword can also use the !=, in and not in operators.

worklogVisibleGroup

The worklogVisibleGroup keyword can be used to find issues that have time logged against them that is restricted so it is only visible to other users in a user group.

project = DEV AND worklogVisibleGroup = 'jira-developers'

This keyword can also use the !=, in and not in operators.

Comments

numberOfComments

The numberOfComments keyword can be used to find issues with a particular number of comments:

resolution = 'Wont Fix' AND numberOfComments > 0

This keyword can be used with the numeric comparison operators.

firstCommentedDate

The firstCommentedDate keyword can be used to search for issues based on the date of the first comment.

created > startOfDay() AND firstCommentedDate = now()
priority = High AND firstCommentedDate < startOfWeek()

This keyword can be used with the JQL relative date functions and also the numeric comparison operators.

lastCommentedDate

The lastCommentedDate keyword can be used to search for issues based on the date of most recent comment.

assignee = currentUser() AND lastCommentedDate < startOfMonth()
status = 'In Progress' AND lastCommentedDate = '2016-10-14'

This keyword can be used with the JQL relative date functions and also the numeric comparison operators.

commentedOn

This keyword can be used to find issues that had a comment made on them on a particular date.

commentedOn = '2016-02-14' AND project = VALENTINE
project = APOLLO AND assignee = narmstrong AND commentedOn in ('1969-07-20', '1969-07-21')

The commentedOn keyword can be used with the following operators: in, not in, != AND =

commentedBy

The commentedBy keyword can be used to search for issues that have comments on them made by a particular user. You must specify a username:

reporter = currentUser() AND commentedBy = 'jsmith'

This keyword can be used with the following operators: in, not in, != AND =

commentVisibleRole

The commentVisibleRole keyword is used to find issues that have comments on them that are restricted to only be visible to users within a particular project role.

project = SUPPORT AND commentVisibleRole = 'Service Desk Team'
priority = Highest AND commentVisibleRole in ('Project Administrator', 'Developer')

This keyword can be used with the following operators: =, !=, in and not in

Tip
Check the ScriptRunner Add-on Permissions before using this JQL alias.

commentVisibleGroup

The commentVisibleGroup keyword is used to find issues that have comments on them that are restricted to only be visible to members of a particular group.

project = TOPSECRET AND commentVisibleGroup = 'Secret Agents'

This keyword can be used with the following operators: =, !=, in and not in

Tip
Check the ScriptRunner Add-on Permissions before using this JQL alias.

lastCommentBy

This keyword can be used to search for issues based on the user who made the most recent comment. You must provide a username:

reporter = 'jsmith' AND lastCommentBy = currentUser()
assignee = currentUser() AND lastCommentBy in ('jbond', 'jbauer')

This keyword can be used with the following operators: =, !=, in and not in

lastCommentVisibleRole

This keyword can be used to search for issues based on whether the most recent comment was restricted to only be viewed by members of a particular project role:

project = SUPPORT AND lastCommentVisibleRole = 'Developers'

This keyword can be used with the following operators: =, !=, in and not in

Tip
Check the ScriptRunner Add-on Permissions before using this JQL alias.

lastCommentVisibleGroup

This keyword can be used to search for issues based on whether the most recent comment was restricted to only be viewed by members of a particular user group:

priority = Low AND lastCommentVisibleGroup = 'Management'

This keyword can be used with the following operators: =, !=, in and not in

Tip
Check the ScriptRunner Add-on Permissions before using this JQL alias.

Comparison with ScriptRunner for Jira Server

See the feature parity table for an extensive list of differences between Scriptrunner for Jira Server and ScriptRunner for Jira Cloud JQL queries.