Sohil
Sohil

Reputation: 41

JIRA / Greenhopper update stories when sub tasks are updated

In my JIRA/Greenhopper, when i move a subtask under story to "In Progress" can I automatically move my story to "In Progress"?

Also when I've closed all the tasks in my story can it automatically move my a story to close.

Upvotes: 3

Views: 2048

Answers (3)

Maxym
Maxym

Reputation: 60

Install a free JIRA Misc Workflow Extensions plugin Edit your "In Progress" transition to add a Post Function to transition parent issue using the same "In Progress" transition (kind of a reference to itself).

Note: Prefer using transition id, as it silently fails if you have several transitions with the same name.

Upvotes: 0

Srividhya
Srividhya

Reputation: 11

currUser = ComponentManager.getInstance().getJiraAuthenticationContext().getUser()
currUserName = currUser.getName()
issueServiceObj = ComponentManager.getInstance().getIssueService()
issueParamImpl = IssueInputParametersImpl()
issueParamImpl.setAssigneeId(currUserName)
issueId = issue.getId()
transValiRes = issueServiceObj.validateTransition(currUser,issueId,91,issueParamImpl)
if(transValiRes.isValid()):
   System.out.println("Transition validated")
   transitionResult = issueServiceObj.transition(currUser,transValiRes)
else:
   System.out.println("in else") 

Please let me know , if I am missing something

Upvotes: 1

Logan
Logan

Reputation: 4337

What you want to do is add post-function to the task's workflow transition from "Open" to In Progress". The post-function should transition the parent User Story from "Open" to In Progress". I used the Jira Scripting Suite plugin and a Jython script to do something similar.

Your algorithm would go something like this:

parentUserStory = task.getParentObject()
if (parentUserStory.getStatusObject().getName() == "Open"):
    inProgressTransitionID = 41 # This is the id of the transition from Open -> In Progress in the User Story workflow*
    workflowManager = ComponentManager.getInstance().getWorkflowManager()
    userStoryWorkflow = workflowManager.getWorkflow(parentObject)
    usCurrentStep = userStoryWorkflow.getLinkedStep(parentObject.getStatus())
    listOfActions = usCurrentStep.getActions()
    for act in listOfActions:
        if str(act) == "In Progress":
            break
        else: 
            log.debug("No match: " + str(act))
    iIP = IssueInputParametersImpl()

    issueService = ComponentManager.getInstance().getIssueService()
transitionValidationResult = issueService.validateTransition(issue.getAssignee(),parentObject.getId(),act.getId(),iIP)

Key points:

  • You don't want to arbitrarily change the issue status. That way madness lies. Instead, transition the issue through its workflow.
  • The actual code for making the transition happen is dependent on your Jira version and the language you choose. It can be complex. Copy-and-pasting the above will doubtless fail. Hopefully it's enough to get you started.
  • Extra resource: answers.atlassian.com.

Upvotes: 1

Related Questions