Subtasks are not created for new fix version


We run groovy post function script which should create sub-task when new fix version is created or new bus is cretaed. It worked fine on JIRA4.3 installation and now JIRA is updated to 5.0. Script was modified a little bit and now subtask is created when new issue is created (even some errors can be found in the log), but adding new fix version does not create new sub task. The errors in the log are (the full log is attached (fixversion_added.log) )

2012-05-10 10:28:01,102 http-80-2 ERROR admin 628x112x1 19x9h8t /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.GroovyRunner] The script failed : javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: log for class: createBranchFixSubTasks
2012-05-10 10:28:01,102 http-80-2 ERROR admin 628x112x1 19x9h8t /secure/CommentAssignIssue.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function
javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: log for class: createBranchFixSubTasks
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(

The script is

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
import com.atlassian.jira.util.JiraUtils
import com.atlassian.jira.util.ImportUtils

class createBranchFixSubTasks {

    def componentManager
    def issueFactory
    def authContext
    def issueManager
    def subtaskManager
    def projectManager

    def createBranchFixSubTasks(){

    def versionIsContainedIn(version, versions) {
        for (ver in versions) {
            if (ver.getName() == version.getName()) {
                log.warn "Found version: " + versions.getName()
                return true
        return false

    def issueHasFixTaskForBranch(branch, issue) {
        for (subtask in issue.getSubTaskObjects()) {
            if (subtask.getIssueTypeObject().getName() == "Branch fix" && versionIsContainedIn(branch, subtask.getFixVersions())) {
                log.warn "Fix issue already created for version: " + branch.getName()
                return true
        return false

    def createFixTask(fixTo, forIssue) {
        def parentSecurityLevel = forIssue.getSecurityLevelId()
        assert (parentSecurityLevel != null)
        def subtask = issueFactory.getIssue()

         for (issuetype in subtaskManager.getSubTaskIssueTypeObjects() ) {
             if (issuetype.getName() == 'Branch fix') {
                //log.warn("Setting issue type to: " +
       // def issuetype = subtaskManager.getSubTaskIssueType('Branch fix')
        //log.warn("Setting issue type to: " +

        //log.warn "Creating issues: " + subtask.toString() + " by " + authContext.getUser()
        com.atlassian.crowd.embedded.api.User user = authContext.getUser()
        def subTaskObject = issueManager.createIssueObject(user, subtask)
        subtaskManager.createSubTaskIssueLink(forIssue, subtask, user)
        //log.warn "Created branch fix issue for: " + fixTo.getName()
    def public processIssue(com.atlassian.jira.issue.MutableIssue issue){

        componentManager = ComponentManager.getInstance()
        issueFactory = componentManager.getIssueFactory()
        authContext = componentManager.getJiraAuthenticationContext()
        issueManager = componentManager.getIssueManager()
        subtaskManager = componentManager.getSubTaskManager()
        projectManager = componentManager.getProjectManager()

        def wasIndexing = ImportUtils.indexIssues
        ImportUtils.indexIssues = true
        def parentIssueNeedsUpdate = false
        for (fixTo in issue.getFixVersions()) {
            if (!issueHasFixTaskForBranch(fixTo, issue)) {
                createFixTask(fixTo, issue)
                parentIssueNeedsUpdate = true

        if (parentIssueNeedsUpdate) {
            issueManager.updateIssue(authContext.getUser(), issue, EventDispatchOption.DO_NOT_DISPATCH, false)
        ImportUtils.indexIssues = wasIndexing


creator = new createBranchFixSubTasks()

could you please tell what might be wrong here?

Thank you in advance.

Cheers, Georgiy

1 answer

1 accepted

0 vote

It's telling you what's wrong I think... "log" is not defined. That variable should be available in the script, but it won't be in the class that you defined in the script.

So you can pass it in in a constructor for the "createBranch..." class, or add to the inner class:

Category log = Category.getInstance(createBranchFixSubTasks.class)

(import import org.apache.log4j.Category).

BTW I'm not aware of anything in this area that would have broken between 4 and 5 - are you sure you didn't refactor the script?

Thank you for pointing me that "log" causes the problem.

As the "log" is used for debuging purpose only then I solved this problem by removing all lines with "log.warn" and problem disappeared.

The script was refactored because original one stopped working since we switched form JIRA4.3 to JIRA5.0

Yes, I guess it was "com.atlassian.crowd.embedded.api.User user".

If you had just used "def user", ie dynamic not static typing it would have worked in 4.3 and 5.0.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

113 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you