我需要能够创建一个Jira问题。但是当选择一个项目来添加问题时,我也需要能够将它添加到另一个项目中。 所以我所拥有的是同样的问题,两个项目团队都可以解决这个问题。
我不需要克隆或链接,因为这会导致创建并需要维护两个问题。
有没有人对我如何处理他有什么想法?也许开发新的插件?
答案 0 :(得分:0)
这可以使用Script Runner add-on完成,只需在create
转换中添加一个脚本,该脚本将在另一个项目中创建相同的问题。
脚本代码(将所有id更改为您自己的代码):
from com.atlassian.jira.util import ImportUtils
from com.atlassian.jira import ManagerFactory
from com.atlassian.jira.issue import MutableIssue
from com.atlassian.jira import ComponentManager
from com.atlassian.jira.issue.link import DefaultIssueLinkManager
from org.ofbiz.core.entity import GenericValue;
# get issue objects
issueManager = ComponentManager.getInstance().getIssueManager()
issueFactory = ComponentManager.getInstance().getIssueFactory()
authenticationContext = ComponentManager.getInstance().getJiraAuthenticationContext()
issueLinkManager = ComponentManager.getInstance().getIssueLinkManager()
customFieldManager = ComponentManager.getInstance().getCustomFieldManager()
userUtil = ComponentManager.getInstance().getUserUtil()
projectMgr = ComponentManager.getInstance().getProjectManager()
customFieldExample = customFieldManager.getCustomFieldObjectByName("custom Field Example")
# define new issue
issueObject = issueFactory.getIssue()
issueObject.setProject(projectMgr.getProject(10000)) # set which project
issueObject.setIssueTypeId("1") # which issue type
# set issue attributes
issueObject.setSummary("[copy from ...] "+issue.getSummary())
issueObject.setAssignee(userUtil.getUserObject("John"))
issueObject.setReporter(issue.getAssignee())
issueObject.setDescription(issue.getDescription())
issueObject.setCustomFieldValue(customFieldExample, issue.getCustomFieldValue(customer_email))
issueObject.setComponents(issue.getComponents())
# Create new issue
newIssue = issueManager.createIssue(authenticationContext.getUser(), issueObject)
# Link parent issue to the new one
issueLinkManager.createIssueLink(issueObject.getId(),issue.getId(),10003,1,authenticationContext.getUser()) # change to your link id
# Update search indexes
ImportUtils.setIndexIssues(True);
ComponentManager.getInstance().getIndexManager().reIndex(newIssue)
ImportUtils.setIndexIssues(False)