the plugin automatically disabled

Issue #22 new
Former user created an issue

jira v7.0.11 and code runner 2.2.2 only one groovy listener script is added.

The problem is the plugin is automatically disabled sometime after running about 1~2 day. I can go to the plugin manager page to enable it, but will disabled again 1~2 days later.

There is no clue in the log.

Need help.

Comments (4)

  1. 高岳

    Here is the script, it is used to calculate the parent ticket's story points based on the remaining sub-task, that output a good burning down graph for agile.

    import com.atlassian.jira.component.ComponentAccessor
    import com.atlassian.jira.event.type.EventDispatchOption
    import com.atlassian.jira.issue.Issue
    import com.atlassian.jira.issue.IssueManager
    import com.atlassian.jira.issue.MutableIssue
    import com.atlassian.jira.issue.UpdateIssueRequest
    import com.atlassian.jira.issue.status.category.StatusCategory
    import com.atlassian.jira.issue.ModifiedValue
    import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
    import com.atlassian.jira.issue.fields.CustomField
    import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem
    
    
    /**
     * Created by ygao on 2019/2/27.
     */
    
    def updateIssue(MutableIssue issue) {
        def user = ComponentAccessor.jiraAuthenticationContext.user
        def issueManager = ComponentAccessor.issueManager
        issueManager.updateIssue(user, issue, createIssueUpdateRequest())
    }
    
    def createIssueUpdateRequest() {
        new UpdateIssueRequest.UpdateIssueRequestBuilder()
                .eventDispatchOption(EventDispatchOption.DO_NOT_DISPATCH)
                .sendMail(false)
                .build()
    }
    
    def updateStoryPoint(MutableIssue issue, Double newStoryPoint) {
        def cfManager = ComponentAccessor.customFieldManager
        def customField = cfManager.getCustomFieldObjectByName("Story Points")
        issue.setCustomFieldValue(customField, newStoryPoint)
        updateIssue(issue)
    }
    
    def getStoryPoint(MutableIssue issue) {
        def cfManager = ComponentAccessor.customFieldManager
        def customField = cfManager.getCustomFieldObjectByName("Story Points")
        return customField.getValue(issue) ? customField.getValue(issue) : 0
    }
    
    def reCalcIssue(sourceIssue) {
        def parentIssue = sourceIssue.subTask ? sourceIssue.parentObject : null
        def isDeleted = $event.eventTypeId == 8
        def isCompleted = sourceIssue.getStatusObject().statusCategory.key == StatusCategory.COMPLETE
    
        println "boss 1: source issue: " + sourceIssue
    
        if (parentIssue != null) {
            println "boss 1: parent issue: " + parentIssue
            println "boss 1: parent sub-tasks are " + parentIssue.subTaskObjects
        }
    
        // 1. update source;
        def sourceStoryPoint = getStoryPoint(sourceIssue)
        if (!isDeleted && sourceIssue.originalEstimate != sourceStoryPoint * 3600 && !sourceIssue.subTask) {
            println "boss 2: Update issue " + sourceIssue.key + " original estimate from " + sourceIssue.originalEstimate + " to " + sourceStoryPoint*3600
            println "boss 2: event.eventTypeId "+ $event.eventTypeId
            sourceIssue.originalEstimate = sourceStoryPoint * 3600
            sourceIssue.estimate = sourceStoryPoint * 3600
            updateIssue(sourceIssue)
        }
    
        // 2. update parent;
        def totalStoryPoint = 0
        println "boss 3: " + parentIssue + " " + parentIssue ? parentIssue.subTaskObjects : null
        if (parentIssue != null && parentIssue.subTaskObjects != null) {
    
            def isContainSourceIssue = false;
            for (Issue subTask in parentIssue.subTaskObjects) {
                def subTaskStoryPoint = getStoryPoint(subTask)
                if (subTask.statusObject.statusCategory.key != StatusCategory.COMPLETE) {
                    totalStoryPoint += subTaskStoryPoint
                }
                if (subTask.id == sourceIssue.id) {
                    isContainSourceIssue = true
                }
                println "boss 3.x: subTask issue: " + subTask.key + " " + subTask.getStatusObject().statusCategory.key + " " + subTask.statusObject.statusCategory.name + " " + subTaskStoryPoint
            }
    
            if (!isContainSourceIssue && !isDeleted && !isCompleted) {
                totalStoryPoint += sourceStoryPoint
            }
            def parentStoryPoint = getStoryPoint(parentIssue)
            if (parentStoryPoint != totalStoryPoint) {
                println "boss 3: Update issue " + parentIssue.key + " story point from " + parentStoryPoint + " to " + totalStoryPoint
                updateStoryPoint(parentIssue, totalStoryPoint)
            } else {
                println "boss 3: Partent issue " + parentIssue.key + " story point doesn't change. " + parentStoryPoint + " " + totalStoryPoint
            }
    
            if (parentIssue.originalEstimate != 0 || parentIssue.estimate != 0) {
                parentIssue.originalEstimate = 0
                parentIssue.estimate = 0
                updateIssue(parentIssue)
            }
        }
    
    
    }
    
    println "boss 0: " + $event
    
    
    reCalcIssue($issue)
    
  2. Log in to comment