简体   繁体   English

詹金斯:System.out.println不在控制台窗口上打印任何内容

[英]Jenkins : System.out.println is not printing anything on console window

I am new to jenkins. 我是詹金斯的新手。 I have created a demo hello world print java file with following code : 我用以下代码创建了一个演示hello world print java文件:

public class Hello{
public static void main(String args[]){
System.out.println("Hello World");
}
}

Saved this file in Jenkins workspace folder. 将此文件保存在Jenkins工作区文件夹中。 When I build this file using jenkins then on command line i am getting following output : 当我使用jenkins构建此文件时,在命令行上我得到以下输出:

C:\.jenkins\workspace\first_project>javac Hello.java 

C:\.jenkins\workspace\first_project>exit 0 
Finished: SUCCESS

But in this console window there is nowhere text as 'Hello World'. 但是在此控制台窗口中,没有任何文本为“ Hello World”。 Please help me out how can I print this on console window. 请帮助我如何在控制台窗口上打印此内容。 Thanks in advance. 提前致谢。

javac Hello.java means compile the program, not run it. javac Hello.java意味着编译程序,而不是运行它。 You probably want to run it afterwards, eg through a shell-command? 您可能想在以后运行它,例如通过shell命令?

Jenkins redirects output to per-job logs. Jenkins将输出重定向到按工作日志。 In this manner, such output can be differentiated from other jobs, otherwise the output of jobs running in parallel would be very difficult to decipher. 以这种方式,可以将这种输出与其他作业区分开,否则并行运行的作业的输出将很难解密。

Look at the output for your job in the Jenkins UI, you should find what you are looking for. 在Jenkins UI中查看工作的输出,您应该找到所需的内容。 Locating build output from Jenkins covers this as well. 从Jenkins查找构建输出也涵盖了这一点。

Using 运用

System.out.println("Hello World");

Is a bad practice, consider using slf4j or any other logging library Logs with slf4j looked good on Jenkins on any project I worked on. 不好的做法是,考虑使用slf4j或任何其他日志记录库在我从事的任何项目上,带有slf4j的日志在Jenkins上看起来都不错。 Create a logger 创建一个记录器

private static final Logger LOG = LoggerFactory.getLogger(LoggableClass.class);

And log with the severity you need 并以您需要的严重性进行记录

LOG.debug("The message");

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

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