Hi,
We have a script that runs on issue updated event. This script just update Fix Version of sub tasks with the Fix Version of the issue.
When we update Fix Version of an issue, it appends this field with the parent version too (we use greenhopper).
After we upgrade to jira 5.2.5, the script stops update with the parent version. It only update with version.
If we run the script in the Script Runner, it works fine.
Can you help us?
I fixed using the getParentObject() from each event.issue.getSubTaskObjects() object instead of event.issue.
package com.libgroovy import com.atlassian.jira.event.issue.AbstractIssueEventListener import com.atlassian.jira.event.issue.IssueEvent import com.atlassian.jira.issue.Issue import com.atlassian.jira.util.ImportUtils import com.atlassian.jira.component.ComponentAccessor import org.apache.log4j.Category import com.atlassian.jira.event.type.EventDispatchOption import com.atlassian.jira.issue.MutableIssue class AtualizarFixVersion extends AbstractIssueEventListener { @Override void workflowEvent(IssueEvent event) { Category log = Category.getInstance(AtualizarFixVersion.class) log.setLevel(org.apache.log4j.Level.DEBUG) log.debug "=============================Inicio do script AtualizarFixVersion ============================" if ((!event.issue.isSubTask()) && (event.issue.getSubTaskObjects() != null)) { def indexManager = ComponentAccessor.getIssueIndexManager() def issueManager = ComponentAccessor.getIssueManager() for (Issue issue in event.issue.getSubTaskObjects()) { issue = issue as MutableIssue; //*****here I changed the event.issue to issue.getParentObject()****** issue.setFixVersions(issue.getParentObject().getFixVersions()); issueManager.updateIssue(event.getUser(),issue,EventDispatchOption.DO_NOT_DISPATCH,false) boolean wasIndexing = ImportUtils.isIndexIssues(); ImportUtils.setIndexIssues(true); indexManager.reIndex(issue); ImportUtils.setIndexIssues(wasIndexing); log.debug " Issue: ${event.issue}\n Issue fix version: ${event.issue.getFixVersions()}\n Parent: ${issue.getParentObject()}\n Parent fix version: ${issue.getParentObject().getFixVersions()}\n Child Issue: ${issue}\n Child fix version: ${issue.getFixVersions()}" } log.debug "==========================================Fim do script=========================================" } } }
Thank you!
I ran into a similar issue, but I can't recall how I fixed it. Nonetheless, here's my own script that ensures sub-tasks version always match their parent.
package com.custom import com.atlassian.jira.event.issue.AbstractIssueEventListener import com.atlassian.jira.event.issue.IssueEvent import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.Issue import com.atlassian.jira.ComponentManager import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.util.UserManager import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.issue.IssueInputParameters import com.atlassian.jira.security.JiraAuthenticationContext import com.atlassian.jira.project.version.Version import com.atlassian.jira.event.type.EventDispatchOption import org.apache.log4j.Category import com.atlassian.jira.issue.changehistory.ChangeHistoryManager import com.atlassian.jira.issue.history.ChangeItemBean import java.util.Calendar import java.util.Date import java.sql.Timestamp class TaskVersionListener extends AbstractIssueEventListener { Category log = Category.getInstance(TaskVersionListener.class) @Override void issueUpdated (IssueEvent event) { log.setLevel(org.apache.log4j.Level.WARN) log.debug ("---- TaskVersionListener starts -----") log.debug ("issue: ${event.issue} || task: ${event.issue.isSubTask()}") // method configuration Calendar cal = Calendar.getInstance() cal.add(Calendar.SECOND, -30) Date date = cal.getTime() Timestamp threshhold = date.toTimestamp() IssueManager issueManager = ComponentAccessor.getIssueManager() UserManager userManager = ComponentAccessor.getUserManager() ChangeHistoryManager changeHistoryManager = ComponentAccessor.getChangeHistoryManager() if (!event.issue.isSubTask()) { List <ChangeItemBean> changeItemBeans = changeHistoryManager.getChangeItemsForField(event.issue,"Fix Version") changeItemBeans.each { item -> log.debug ("Fix Version created at ${item.getCreated()} with threshhold of $threshhold") if (item.getCreated().after(threshhold)) { log.debug ("green light for item above!") event.issue.getSubTaskObjects().each { t -> if (!t.getStatusObject().getName().equals("Done")) { MutableIssue myIssue = t myIssue.setFixVersions(event.issue.getFixVersions()) issueManager.updateIssue(userManager.getUser("automation"), myIssue, EventDispatchOption.DO_NOT_DISPATCH, false) } } } } } else { List <ChangeItemBean> changeItemBeans = changeHistoryManager.getChangeItemsForField(event.issue,"status") changeItemBeans.each { item -> log.debug ("created at ${item.getCreated()} with threshhold of $threshhold") if (item.getCreated().after(threshhold) && item.getFromString().equals("Done")) { log.debug ("green light for item above!") MutableIssue myIssue = event.issue myIssue.setFixVersions(event.issue.getParentObject().getFixVersions()) issueManager.updateIssue(userManager.getUser("automation"), myIssue, EventDispatchOption.DO_NOT_DISPATCH, false) } } } log.debug ("---- TaskVersionListener ends ------") } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you,
I'm doing the same thing but the time verification. I'm applying an reindex on subtasks too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you,
I'm doing the same thing but the time verification. I'm applying a reindex on subtasks too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I fixed replacing event.issue.getFixVersions for a call to getParentObject() on each sub task object of the issue.
The log was:
Issue: WTES-33
Issue fix version: [Version 1.01]
Parent: WTES-33
Parent fix version: [Version 1.0, Version 1.01]
Child Issue: WTES-34
Child fix version: [Version 1.0, Version 1.01]
Issue and Parent are the same object, but the fix version value is different.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a version called "Release 1.01". It's a child version of "Version 1.0".
When I update the issue fix version, setting with "Release 1.01"(the child) automatically it puts "Version 1.0"(the parent) on Fix Version field separeted by comma.
On Jira prior version, when I perform this, the script set subtask fix version with "Version 1.0, Release 1.01".
Now it's just set with "Release 1.01".
The script update the subtask issue, but on log when I run event.issue.getFixVersions() it only returns "[Release 1.01]" instead "[Version 1.0, Release 1.01]".
The script is running before set the Parent version.
Before we update jira it didn't happen.
The log does not report any error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We'd need more info other than it doesn't work... eg any errors in logs? Have you added some debug so you can see what your script is trying to do?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.