包括下游/子Jenkins作业的控制台输出到触发作业的控制台输出 [英] include downstream/child Jenkins job's console output into triggering job's console output

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

问题描述

2 Jenkins jobs:A and B。

2 Jenkins jobs: A and B.

A触发B作为阻塞构建步骤(阻塞,直到触发项目完成构建)。有没有办法将B的控制台输出包含到A的控制台输出?

A triggers B as blocking build step ("Block until the triggered projects finish their builds"). Is there a way to include B's console output into A's console output?

动机:为浏览器使用Jenkins A的控制台输出包含一个链接到B的控制台输出。但是当通过命令行工具(jenkins-cli)使用Jenkins时,没有快速简单的方法来查看B的控制台输出。

Motivation: for browser use of Jenkins A's console output contains a link to B's console output which is fine. But when using Jenkins via command line tools (jenkins-cli) there's no quick and easy way to see B's console output.

任何想法?

推荐答案

有趣。我会尝试这样的。

Interesting. I'd try something like this.

http:// jenkinsurl / job / jobname / lastBuild / api /

访问渐进式控制台输出

您可以检索正在进行的控制台输出使用参数重复GET请求。你基本上会发送GET请求到这个URL(或者这个URL,如果你想要的HTML可以放到标签。)start参数控制字节偏移的开始。

Accessing Progressive Console Output
You can retrieve in-progress console output by making repeated GET requests with a parameter. You'll basically send GET request to this URL (or this URL if you want HTML that can be put into tag.) The start parameter controls the byte offset of where you start.

响应将包含控制台输出的一个块,以及表示原始日志文件的字节偏移量的X-Text-Size标头。这是您要用作下一次调用的开始参数的数字。

The response will contain a chunk of the console output, as well as the X-Text-Size header that represents the bytes offset (of the raw log file). This is the number you want to use as the start parameter for the next call.

如果响应还包含X-More-Data:true标头,则服务器指示构建正在进行中,并且您需要在一段延迟后重复请求。 Jenkins UI在进行下一个调用之前等待5秒钟。当此标题不存在时,您知道您已检索所有数据,并且构建完成。

If the response also contains the X-More-Data: true header, the server is indicating that the build is in progress, and you need to repeat the request after some delay. The Jenkins UI waits 5 seconds before making the next call. When this header is not present, you know that you've retrieved all the data and the build is complete.

下游作业,但不阻塞直到下游完成。而是,添加一个额外的步骤( execute shell ,可能),并编写一个脚本,将读取其他作业的控制台输出,如上所示,并显示在控制台输出当前工作。你将不得不通过寻找 X-More-Data:true 头来检测子作业的完成时间,如上所述。

So you can trigger a downstream job, but don't "block until downstream completes". Instead, add an extra step (execute shell, probably) and write a script that will read the console output of the other job as indicated above, and display it in console output of current job. You will have to detect when the child job finished by looking for X-More-Data: true header, as detailed above.

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

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