在Jira Scriptrunner内联编辑器中调试Groovy

在Jira Scriptrunner内联编辑器中调试Groovy,groovy,jira,Groovy,Jira,我是一名程序员,刚刚开始在Jira中使用groovy,以便自动化一些任务 我正在尝试使用Jira中的内联编辑器编写一个自定义侦听器脚本,但还没有通过让Hello World程序工作的尝试 我不知道脚本是否正在运行,也看不到任何输出,我真的需要一些帮助来弄清楚如何调试脚本,最好是通过输出到某种控制台(或者如果需要,甚至只是通过阅读Jira日志),这样我就可以真正开始尝试学习如何使用这个工具 我正在使用这些信息作为开始学习使用内联编辑器的一般指南 要了解更多的上下文,您可以看到我提出的另一个相关问题

我是一名程序员,刚刚开始在Jira中使用groovy,以便自动化一些任务

我正在尝试使用Jira中的内联编辑器编写一个自定义侦听器脚本,但还没有通过让Hello World程序工作的尝试

我不知道脚本是否正在运行,也看不到任何输出,我真的需要一些帮助来弄清楚如何调试脚本,最好是通过输出到某种控制台(或者如果需要,甚至只是通过阅读Jira日志),这样我就可以真正开始尝试学习如何使用这个工具

我正在使用这些信息作为开始学习使用内联编辑器的一般指南

要了解更多的上下文,您可以看到我提出的另一个相关问题

根据找到的信息,我已将附加侦听器的事件的调试级别设置为debug,如本屏幕截图所示:

这是我在JIRA工作的内联编辑器的屏幕截图。在这个屏幕截图中,我只是想输出“Hello”,并单击了“Preview”按钮:

如您所见,在屏幕底部的“结果”选项卡中,没有任何感兴趣的内容。“日志”选项卡也是空的,“计时”选项卡只显示“已用时间:0毫秒CPU时间:0毫秒”,因此如果发生这种情况,似乎什么都没有

如果我检查服务器上的日志(在catalina.2017-10-13.txt文件中),我会看到以下输出:

13-Oct-2017 07:01:50.942 WARNING [http-nio-8080-exec-6] com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters A servlet request, to the URI http://somevmserver:8080/rest/scriptrunner-jira/latest/listeners/com.onresolve.scriptrunner.canned.jira.workflow.listeners.CustomListener/params, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
13-Oct-2017 07:02:26.740 WARNING [http-nio-8080-exec-12] com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters A servlet request, to the URI http://somevmserver:8080/rest/scriptrunner/latest/canned/com.onresolve.scriptrunner.canned.common.StaticCompilationChecker, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
13-Oct-2017 07:02:26.974 WARNING [http-nio-8080-exec-1] com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters A servlet request, to the URI http://somevmserver:8080/rest/scriptrunner-jira/latest/listeners/com.onresolve.scriptrunner.canned.jira.workflow.listeners.CustomListener/preview, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
这个输出对我来说意义不大,但很明显,它是在尝试预览脚本后填充的

我在内联编辑器中没有发现任何错误,而且它的代码非常简单,所以我认为不是这样

我可以包含的唯一其他相关信息是,这是从我们的生产环境克隆的Jira的测试实例,其基本URL仍然设置为prod环境的URL。不确定这是否有任何关系,但我不是一个真正的Jira管理员,只是负责做这件事的程序员,所以我不想在我不需要的地方胡闹

谢谢

要在日志中查看调试消息“Hello”,必须更新所选项目中的问题。因此,底部的日志和计时选项卡在此视图中是无用的。只需在所选项目中使用问题更新触发侦听器,并在atlassian-jira.log文件中搜索调试消息


提示:要在浏览器中查看日志,您可以使用此jira应用程序

在jira中使用scriptrunner时,您需要导入记录器以使用调试器或输出到控制台。这可以通过以下方式完成:

// Enable debugger
import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
然后,您可以使用
log.debug“hello”