在内部Jenkins作业中使用Groovy记录器时无法正常工作 [英] Groovy logger is not working when using inside Jenkins jobs

查看:151
本文介绍了在内部Jenkins作业中使用Groovy记录器时无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个詹金斯(Jenkins)工作,该工作称为groovy脚本.我在groovy脚本中使用了一个简单的logger(用于STDOUT).但是,由于某种原因,它根本无法工作.

I have a jenkins job which calls a groovy script. I have used a simple logger (for STDOUT) inside the groovy script. But, for some reason, it is not working at all.

我的代码如下:

import hudson.model.*
import java.util.logging.Logger

Logger logger = Logger.getLogger("")
logger.info("I am a test info log")

logger.info("Starting script VersionNumber.groovy 1 ...")

....

有什么办法可以解决这个问题?

Is there any way to make it work out?

提前谢谢!

推荐答案

我假设您是指作业的输出,而不是Jenkins的实际"标准输出.我还假设您正在使用Groovy Postbuild脚本.

I assume that you are referring to the output of the job and not the 'real' stdout of Jenkins. I also assume you are using the Groovy Postbuild script.

在Groovy postbuild中,有一个可用的'manager'实例,它是各种操作的关键.有关详细信息,请参见插件页面.

In Groovy postbuild there is an available instance of 'manager' which serves as a key to all sorts of operations. See the plugin page for details.

写入作业的输出是由侦听器内部的记录器完成的:

Writing to the output of the job is done by a logger inside the listener:

manager.listener.logger.println "Hello"

据我所知,在工作中无法掌握真实"标准输出或Jenkins日志文件.

Getting hold of the 'real' stdout or the Jenkins log file is to my knowledge not possible from within a job.

这篇关于在内部Jenkins作业中使用Groovy记录器时无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆