Feel free to download this JIRA Cheat sheet with the list of shortcuts as well as many available operators of JIRA Query Language (JQL) for advanced searches.
Add labels when creating issue on JIRA
JIRA is definitely a flexible bug tracking tool and one of the most powerful features is workflow customization. This post describes how to add a label automatically when an issue is created. This can be useful when you want to flag an issue and later capture that in a filter or board. A practical example is to flag Bugs that are created so that they can be reviewed during Bug Scrub meetings. In order to add a label we need to add a custom script in a post-function.
- As admin, go to Administration >> Issues >> Workflows >> Click on Edit in the workflow you want to change
- Click on the ‘To Do’ step (assuming your workflow is the default one)
- Click on the ‘Create’ action >> Post Functions tab >> Add post function
- Select Script Post-Function >> Custom script post-function
- Paste the following code snippet replacing ‘BugScrub’ by the tag you want
- Publish the workflow => Important: If you don’t publish the draft workflow, no changes will be reflected.
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.label.LabelManager import com.atlassian.jira.component.ComponentAccessor def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser() LabelManager mgr = ComponentAccessor.getComponent(LabelManager.class) mgr.addLabel(user, issue.id, 'BugScrub', false)
For additional information about the addLabel method, please refer to the official documentation.
WAS operator in JIRA
JIRA is one of the most used bug tracking system and one of its main features is the search mechanism. There are two modes when searching for issues on JIRA: Basic and Advanced. The basic one is composed of a set of filters you can select and define values. Even though the basic mode is enough for most cases, it does not allow you to run some more complex queries.
Today I’ll present the WAS operator that can be used by writing JQL queries in Advanced mode and that allows you to search for issues based on the property values in the past. This can be extremely useful if you want, for instance, to collect history data or to evaluate changes against to such a property.
This operator can only be used with the following properties: Assignee, Fix Version, Priority, Reporter, Resolution and Status fields only.
Find all bugs that were open last week
issuetype in (Bug, Defect) AND resolution WAS IN (Unresolved, EMPTY) before endOfWeek(-7d)
Find all stories that were resolved last week and that are now closed
issuetype = Story AND status WAS Resolved DURING (startOfWeek(-7d), endOfWeek(-7d)) AND status = Closed
Find all stories that were unassigned in the last two days
issuetype = Story AND assignee WAS EMPTY DURING (endOfDay(-2d), now()) AND assignee IS NOT EMPTY