dannyman.toldme.com


JIRA

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
try:
    timelogged = dict(issue.getModifiedFields())['worklog']
except:
    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

Next:
Previous:
Categories: JIRA

Responses

December 1st, 2011

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…. :(

December 2nd, 2011

Daniel Howard

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.

October 8th, 2012

ttamirt

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

October 2nd, 2015

Timon M

@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.

Comment

Leave a comment . . .

Tiny Print:

  1. For private messages, e-mail me: dannyman@toldme.com.
  2. You must provide an e-mail address.
  3. You can use a bogus e-mail address, but I like to know who you are.
  4. I will not spam you. I will not publish or share your e-mail address.
  5. First-time commenters will be held for review.
  6. You can use these HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>