创建问题时,“修复版本”字段将设置为特定值(例如2.0)。然后创建子任务,并继承该值。到现在为止还挺好。但是如果稍后修改了问题的修复版本值(比如1.0),则子任务仍保留2.0修订版本值。
是否有可用于保持这些字段同步的插件或技术?
注意:这已被要求作为JIRA功能,但Atlassian似乎不想这样做。 https://jira.atlassian.com/browse/JRA-9016
答案 0 :(得分:4)
我知道这是一个古老的问题。但这是我最近部署的代码。这是从ScriptRunner插件在Script Listener上部署的issueUpdated事件的事件侦听器。很多代码来自Jamie Echlin的例子。当父母的修复版本字段被制作时,它仍需要进行调整,并且#34;空的",它的子任务也需要为空。
package com.custom.listeners
import org.apache.log4j.Category
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.project.version.Version
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.type.EventDispatchOption
import java.util.ArrayList
import java.util.Collection
class FixVersionPBI_To_SBI_1 extends AbstractIssueEventListener
{
Category log = Category.getInstance(FixVersionPBI_To_SBI_1.class)
@Override
void issueUpdated(IssueEvent event)
{
try
{
Issue fix_Issue = event.getIssue()
if (fix_Issue.issueTypeObject.name == "Parent issue type" )
{
List changeItems = event.getChangeLog().getRelated("ChildChangeItem")
if( fix_Issue.fixVersions?.name && changeItems.any {it.get('field')=='Fix Version'} )
{
Collection<Version> fixVersions = new ArrayList<Version>();
fixVersions = fix_Issue.getFixVersions()
Collection subTasks = fix_Issue.getSubTasks();
SubTaskManager subTaskManager = ComponentManager.getInstance().getSubTaskManager();
if (subTaskManager.subTasksEnabled && !subTasks.empty)
{
IssueManager issueManager = ComponentManager.getInstance().getIssueManager()
Collection _subTasks = fix_Issue.getSubTaskObjects()
_subTasks.each
{
it.setFixVersions(fixVersions)
issueManager.updateIssue(event.getUser(), it, EventDispatchOption.ISSUE_UPDATED, false)
}
}
}
}
}
catch (ex)
{
log.debug "Event: ${event.getEventTypeId()} fired for ${event.issue} and caught by FixVersionPBI_To_SBI_1"
log.debug (ex.getMessage())
}
}
}
答案 1 :(得分:0)
要手动执行此操作,您可以执行查询,例如“parent = TEST-123”,然后进行批量修改。要自动执行此操作,您需要具有自定义侦听器(例如,脚本运行程序)来检测“问题更新”事件,并且只有在更改是问题更新时才执行某些操作。更新子任务修复版本还需要重新编制子任务索引,否则搜索将无法按预期工作。
我不知道有一个插件可以做到这一点。
答案 2 :(得分:0)
对于Jira 6.4
您的子任务fixversion字段将自动更新。
添加此脚本,测试并保存。
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.config.SubTaskManager;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.event.type.EventDispatchOption;
def result = "";
def subTasks = issue.getSubTaskObjects()
Collection fixVersions = issue.getFixVersions();
if (!fixVersions.empty) {
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager();
if(subTaskManager.subTasksEnabled && !subTasks.empty) {
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
subTasks.each {
if (it.statusObject.name != "Closed") {
it.setFixVersions(fixVersions);
IssueManager issueManager = ComponentAccessor.getIssueManager()
result += it.getKey() + " ";
issueManager.updateIssue(user, it, EventDispatchOption.ISSUE_UPDATED, false);
}
}
if (count > 0) {
result += " versions updated";
}
}
}
return result;