groovy 如何在Jira中更新问题的评论

kyks70gy  于 2022-11-01  发布在  其他
关注(0)|答案(1)|浏览(172)

我正在尝试将一些文本连接到用户输入的注解中。我该怎么做呢?下面是我的代码。我需要访问用户输入的注解,然后向其中添加新的文本。我该怎么做呢?我正在使用Jira ScriptRunner自定义后置函数,当用户单击一个过渡时,该后置函数将被执行。

import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.workflow.WorkflowManager
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor

def log = Logger.getLogger("atlassian-jira.log")
log.warn("This is the last action ")

WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
JiraWorkflow workflow = workflowManager.getWorkflow(issue);
List <Object> actions = workflow.getLinkedStep(issue.getStatus()).getActions(); 

def wfd = workflow.getDescriptor()
def actionName = wfd.getAction(transientVars["actionId"] as int).getName(); 

log.warn("This is the last action "+actionName)
def comment= "+++ added via workflow action "+"\""+actionName+"\"+++"
jgwigjjp

jgwigjjp1#

这是代码transientVars是要走的路。

import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.workflow.WorkflowManager
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor

def log = Logger.getLogger("atlassian-jira.log")
log.warn("This is the last action ")

WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
JiraWorkflow workflow = workflowManager.getWorkflow(issue);

def wfd = workflow.getDescriptor()
def actionName = wfd.getAction(transientVars["actionId"] as int).getName(); 

log.warn("This is the last action "+actionName)
def comment= "+++ added via workflow action "+"\""+actionName+"\"+++"
String content = transientVars["comment"] +"\n"+comment  as String
log.warn("CONTENT"+ content)
transientVars["comment"]= content

相关问题