Make Worklog Description Mandatory Under Specific Conditions

Most of the time work performed on an issue is already recorded with a commit message to GIT or directly obvious from issue itself. But under specific situations you may want to make work description required for example if you are billing each worklog to your customer your customer may want you to record work description. Following scripts make worklog description required under various conditions.

Make Work Description Required If Issue Summary Contains Specific Words

These words may be anything, for example an invoice number a contract number. You may also use a regular expression to check for patterns in issue summary or you can use any other field on the issue.

def specialWordsThatRequreWorkDescription = ["PP0212", "AA2013"]; //update words inside this array for your case def issueSummary = worklog.issue.summary; def foundWord = specialWordsThatRequreWorkDescription.find {sw -> issueSummary.indexOf(sw) > -1}; if (foundWord != null) { return "You need to specify a work description because issue summary contains " + foundWord; } return null;

Make Work Description Required For Specific Projects

Some of your projects may be specific to clients and billed to them so they may require record a description of every worklog, they are the paying for worklogs in the end.

def mandatoryWorkDescriptionForProjects = ["ERP", "ACN"]; //worklog description is required for these projects def issue = worklogResult.getWorklog().getIssue(); def project = issue.getProjectObject(); if (mandatoryWorkDescriptionForProjects.contains(project.getKey())) { def workDescription = worklog.getComment(); if (workDescription == null || workDescription.length() < 3) { //if no description of it's length is less than 3 don't accept worklog return "Work description is mandatory for " + project.getName(); } }