Jenkins - 使用节点名称作为所有日志的前缀?

发布于 2025-01-14 07:23:49 字数 1042 浏览 0 评论 0原文

我正在寻找的功能基本上与 Timestamper 提供的功能相同,但除了显示时间之外对于每一行,我还想查看它在哪个节点上运行。

而不是这个:

13:35:12  > Task :compileJava NO-SOURCE
13:35:12  > Task :processResources NO-SOURCE
13:35:12  > Task :classes UP-TO-DATE
13:35:12  > Task :compileTestJava NO-SOURCE
13:35:12  > Task :processTestResources NO-SOURCE
13:35:12  > Task :testClasses UP-TO-DATE
13:36:39    fatalError

我想要这个(或类似的):

13:35:12 [mac-01] > Task :compileJava NO-SOURCE
13:35:12 [mac-01] > Task :processResources NO-SOURCE
13:35:12 [mac-01] > Task :classes UP-TO-DATE
13:35:12 [mac-01] > Task :compileTestJava NO-SOURCE
13:35:12 [mac-01] > Task :processTestResources NO-SOURCE
13:35:12 [mac-01] > Task :testClasses UP-TO-DATE
13:36:39 [mac-01]   fatalError

我们有在多个节点上并行运行多个构建的管道,有时它们会由于特定节点的问题而失败。如果日志中的每一行都以其正在运行的节点为前缀,那么找出哪个节点出现问题将是非常简单的。就目前情况而言,这可能相当具有挑战性。

我一直在尝试在谷歌上搜索类似的内容,但这些术语有点太笼统,我没有得到任何相关结果。

What I am looking for is basically the same functionality that Timestamper provides, but in addition to showing the time for each line, I also want to see which node it was running on.

Instead of this:

13:35:12  > Task :compileJava NO-SOURCE
13:35:12  > Task :processResources NO-SOURCE
13:35:12  > Task :classes UP-TO-DATE
13:35:12  > Task :compileTestJava NO-SOURCE
13:35:12  > Task :processTestResources NO-SOURCE
13:35:12  > Task :testClasses UP-TO-DATE
13:36:39    fatalError

I want this (or similar):

13:35:12 [mac-01] > Task :compileJava NO-SOURCE
13:35:12 [mac-01] > Task :processResources NO-SOURCE
13:35:12 [mac-01] > Task :classes UP-TO-DATE
13:35:12 [mac-01] > Task :compileTestJava NO-SOURCE
13:35:12 [mac-01] > Task :processTestResources NO-SOURCE
13:35:12 [mac-01] > Task :testClasses UP-TO-DATE
13:36:39 [mac-01]   fatalError

We have pipelines that run multiple builds on multipe nodes in parallel and sometimes they fail due to problems with a specific node. If each line in the log was prefixed with the node it was running on, it would be quite trivial to find out which node is having an issue. As it stands now, it can be rather challenging.

I've been trying to search for something like this on Google, but the terms are a bit too generic and I'm not getting any relevant results.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如痴如狂 2025-01-21 07:23:49

您正在寻找的是标签属性。

此标签属性适用于所有 bat、sh、powershell 等。
https://www.jenkins .io/doc/pipeline/steps/workflow-durable-task-step/#sh-shell-script

bat( script: ```Some Script ```,
     label: "${env.NODE_NAME}"
 )

然后,您的执行将使用运行任务的 NODE_NAME 进行前缀。

What you are looking for is label attribute.

This label attribute is available for all bat, sh, powershell and others.
https://www.jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#sh-shell-script

bat( script: ```Some Script ```,
     label: "${env.NODE_NAME}"
 )

Your execution will then be pre fixed with the NODE_NAME where the task is running.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文