JIRA: Require User Time Tracking

Time tracking in JIRA is a nice feature, but we have to get people to do it. My initial attempts to enforce time tracking ran into trouble, but I was able to develop a Jython Validator to hook on to transitions to the Resolved state. Now it is mandatory for our users to log time worked before they can resolve an issue:

# -*- coding: UTF-8 -*-
import com.atlassian.jira.issue.worklog.Worklog
from com.atlassian.jira import ComponentManager
# Time Already Logged
timespent = issue.getTimeSpent()
# Time Logged via current screen
    timelogged = dict(issue.getModifiedFields())['worklog']
    timelogged = False
# Duplicate Issue?  It is as good as logged!
resolution = issue.getResolution()
if resolution['name'] == "Duplicate":
    timelogged = True
if resolution['name'] == "Self Corrected":
    timelogged = True
# Nagios likes to close tickets, but doesn't get paid
user = ComponentManager.getInstance().getJiraAuthenticationContext().getUser()
if user.getName() == "nagios":
    timelogged = True
if timespent < = 0 and timelogged == False:
    result = False
    description = "Please log the time you spent on this ticket."

2012-01-24 Update: the script now contains additional logic, which exempts the nagios user from enforcement and allows resolution of duplicated or self-correcting issues which may not require time tracking. Hopefully this example is useful to somebody.

Read More

Categories: JIRA

  • Jenny Benevento

    i am the WORST at time tracking but I would think it would be super useful in jira since i spend most of my time there anyway. however there are so many required fields in some jira implementations that it prevents people from opening them, IME and thus tracking gets diverted…. :(

  • So, from what I can see, an important part of JIRA is having sane, clever people managing the damn thing.  That can make the difference between an issue-tracking paradise and a Hell on Earth.

    Because the time tracking isn’t a normal field I couldn’t just make a validation check on the field itself.  I was able to have time tracking as a condition for resolution, but that gets confusing because that hides the Resolve button.  So … this is a slightly more elaborate way of just double-checking and nagging the user to do some time tracking. 

    And yeah, when it is working well JIRA is damn handy maybe not so much for tracking how you spent your day, but for evaluating the “cost” of different tasks.  We use that in our metrics to identify . . . areas for improvement in the way we do things.

  • ttamirt

    i’ve run this scipt in Jython Runner, but no results. I can still resolve issues with 0 timelog. What should I do?

  • @dannyman:disqus can you take a look at our time tracking addon for Jira, may it is what you are looking for. Here is a short description: http://cronforce.com/integrations/jira.html . Hope you don’t mind jumping in.