简体   繁体   English

如何从Java写注释到Jenkins日志?

[英]How to write comment from java to Jenkins log?

I have test in java that run on Jenkins. 我在Jenkins上运行的Java中进行了测试。

Is it no possible to debug that test and therefore I want to add dummy comment to the java and also to see values of variables I want to see it in the console output of the Jenkins ? 是否不可能调试该测试,因此我想向Java添加虚拟注释,并在Jenkins的控制台输出中查看我想查看的变量值? How I can do it ? 我该怎么办? System.out.println() did not work for me System.out.println()对我不起作用

If you use a java testing framework like JUnit, then any tests run will be logged by Jenkins, including any print statements that the tests execute. 如果您使用JUnit之类的Java测试框架,则Jenkins将记录所有运行的测试,包括测试执行的所有打印语句。

Jenkins also has a plugin specifically for JUnit (found here) , which will publish the results so you can easily access them in Jenkins, allowing you to see if tests fail, and then inspect anything printed out, as well as the stack trace, for any given test. Jenkins还有一个专门用于JUnit的插件(在此处找到) ,它将发布结果,以便您可以在Jenkins中轻松访问它们,从而使您可以查看测试是否失败,然后检查所有打印出的内容以及堆栈跟踪,以便任何给定的测试。

If your junit tests are being run by an ant task, then you can simply add a formatter to your task. 如果您的junit测试是由ant任务运行的,则只需将格式化程序添加到任务中即可。 For example: 例如:

<target name="unit-tests">
    <junit>
        ...
        <formatter type="plain" usefile="false" />
    </junit>
</target>

Copied directly from this post 直接从此帖子复制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM