Jenkins作业没有看到控制台输出 [英] Jenkins job not seeing console output

查看:296
本文介绍了Jenkins作业没有看到控制台输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我不是管理员,因此可能存在一些配置不正确的问题,从而导致此问题.我可以配置一个我可以配置的任务,仅此而已.

First, I'm not the admin, so there might be something config-wise that's not correct, leading to this issue. I can configure the one job I have access to configure and that is all.

我正在使用外壳程序脚本(使用git-bash.exe)和Windows批处理文件的组合执行Windows构建.唯一的jenkins构建脚本是仅包含以下内容的shell脚本:

I am performing a Windows build, using a combination of shell scripts (using git-bash.exe) and Windows batch file. The sole jenkins build script is a shell script containing only:

#!c:\Program Files\Git\git-bash.exe
$WORKSPACE/builds/step1.sh |& tee $WORKSPACE/build_output.log

(我的git-bash.exe版本为'4.3.42(5)-release',而|&速记似乎与2>&1 |一样有效.)

(My git-bash.exe version is '4.3.42(5)-release' and the |& shorthand appears to be working as well as 2>&1 | did.)

该脚本(step1.sh)做一些准备工作,然后通过依次调用批处理文件和shell脚本开始构建过程.

That script (step1.sh) does some prep work and then kicks off the build process by calling batch files and shell scripts in sequence.

构建工作正常,我得到了一个不错的MSI文件. build_output.log文件包含整个构建过程的完整日志,这也显示在从属服务器的控制台中.

The build works and I am rewarded with a nice MSI file. The build_output.log file contains a full log of the entire build process as was also displayed in the console on the slave.

问题是,jenkins无法捕获该控制台输出(即build_output.log的内容).我看到的控制台输出是:

The problem is, jenkins fails to capture that console output (ie, the contents of build_output.log). All I see for console output is:

Started by user Jon
[EnvInject] - Loading node environment variables.
Building remotely on Win2k12r2_x64-build (Build VM (xx.xx.xx.xx) Windows Client) in workspace /f/git/project
[project] $ c:\Program Files\Git\git-bash.exe C:\Users\ADMINI~1\AppData\Local\Temp\1\hudson386179994146389782.sh
Notifying upstream projects of job completion
Finished: SUCCESS

我需要怎么做才能在jenkins中捕获构建日志?我特别不想将我的step1.sh脚本放入jenkins,因为我希望能够精确地重现构建团队(管理jenkins服务器)在构建失败时看到的内容.我们希望构建脚本在源代码控制下,对所有人可用,并且可由所有人运行(在其自己的沙箱中).我确实只是尝试从jenkins两行shell脚本中获取构建日志,以查看是否捕获到了它……没有.

What do I need to do to capture the build log in jenkins? I specifically don't want to put my step1.sh script into jenkins since I want to be able to exactly reproduce what the build team (who manage the jenkins server) see when a build fails. We want the build scripts under source control, available to all and runnable by all (in their own sandbox). I did try simply cat-ing the build log from the jenkins two-line shell script to see if that captured it... it did not.

推荐答案

我在Jenkins中使用了类似的命令来准备日志:

I've used a similar command in Jenkins to tee a log:

./foo.sh 2>&1 | tee output.txt

(我使用的Jenkins服务器上的git-bash.exe版本不支持|&,因此我不得不使用长格式来重定向stderr.)

(The version of git-bash.exe on the Jenkins server I was using did not support |&, so I had to use the long form to redirect stderr.)

在您的情况下,如果控制台日志或build_output.log都不包含任何文本,那么我猜它是以下之一:

In your case, if neither the console log or build_output.log contain any text, I'm guessing it's one of the following:

  1. step1.sh实际上没有输出任何东西

  1. step1.sh is not actually outputting anything

故障排除::在Jenkins中运行该脚本而不进行任何重定向或tee,并确认该脚本可将某些内容打印到控制台.如果您的Jenkins环境中的某些问题(例如Jenkins插件)引起了问题,请不要仅依赖于本地运行.

Troubleshoot: Run that script in Jenkins without any redirection or tee, and verify it prints something to the console. Don't rely only on a local run in case something in your Jenkins environment (such as a Jenkins plugin) is causing the problem.

|&静默失败

故障排除::将作业配置为运行echo foo>&2 |& cat,并确认您在控制台中看到"foo".如果失败,请尝试以下长格式:echo foo>&2 2>&1 | cat.

Troubleshoot: Configure your job to run echo foo>&2 |& cat, and verify you see "foo" in your console. If that fails, try the long form: echo foo>&2 2>&1 | cat.

tee静默失败

故障排除::将作业配置为运行echo foo>&2 |& tee out.txt,并确认您在控制台和out.txt中都看到了"foo".如果失败,请尝试以下长格式:echo foo>&2 2>&1 | tee out.txt.

Troubleshoot: Configure your job to run echo foo>&2 |& tee out.txt, and verify you see "foo" in both your console and out.txt. If that fails, try the long form: echo foo>&2 2>&1 | tee out.txt.

这篇关于Jenkins作业没有看到控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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