Jenkins Pipeline sh 显示名称/标签 [英] Jenkins Pipeline sh display name/label

查看:33
本文介绍了Jenkins Pipeline sh 显示名称/标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Jenkins 2 流水线插件,有一个有用的功能允许快速概览流水线阶段和步骤状态,包括日志输出.

With Jenkins 2 Pipeline plugin, there's a useful feature allowing a quick overview of the pipeline stages and status of steps, including logging output.

但是,如果您使用Shell 脚本"(sh) 步骤,似乎没有办法用有用的名称标记该脚本,因此显示屏仅显示一长串Shell 脚本"(如下图所示).

However, if you use the "Shell script" (sh) step, there doesn't seem to be a way to label that script with a useful name, so the display merely shows a long list of "Shell Script" (shown in the image below).

如何指定一个有用的名称,或者如何使用其他步骤来达到相同的效果?

How can I assign a useful name, or how can I use some other step to accomplish the same effect?

推荐答案

2019 年 2 月更新:

根据 gertvdijk 的回答如下,现在可以 为 sh 步骤分配一个可选标签,从 v2.28 开始,以及对于那些还不能升级的人,还有一个解决方法.请查看他的回答了解详情和评论!

According to gertvdijk's answer below, it is now possible to assign an optional label to the sh step, starting from v2.28, and for those who can't upgrade yet, there's also a workaround. Please check his answer for details and comments!

以前的版本(悬停查看):

Previous version (hover to see it):

据我所知,目前这是不可能的.在詹金斯跟踪器,存在 名称或别名 Shell Script Step (sh) 问题这与您的情况类似:

As far as I know, that's currently not possible. In the Jenkins tracker, there is a Name or alias Shell Script Step (sh) issue which is similar to your situation:

sh 步骤在管道中添加了一个Shell 脚本"步骤.然而,可能有多个这样的步骤,包括来自不同的步骤插件(例如 Docker),这使得很难区分步骤.我们或许应该向 sh 添加一个可选参数来指定名称或然后将出现在管道步骤中的别名.例如,以下可能是 npm 的步骤,显示为Shell脚本:npm"在管道视图中.

sh cmd:"npm install",名称:"npm"
The sh step adds a "Shell Script" step in the Pipeline. However, there could be multiple such steps including steps from various plugins (e.g., Docker), which makes it hard to distinguish the steps. We should perhaps add an optional parameter to sh to specify a name or alias which would then appear in the pipeline steps. e.g., the following can be the step for npm which would show as "Shell script: npm" in the pipeline view.

sh cmd:"npm install", name: "npm"

但是,它作为旧版 Allow stage to作为最近修复的标记块操作,并且似乎包含在 pipeline-stage-step 的 v2.2 中-插件(见更新日志).

似乎现在可以嵌套阶段,它们将出现在查看表,但我认为这不是您要查找的内容.

However, it was closed as a duplicate of the older Allow stage to operate as a labelled block which has been fixed recently and seems to be included in v2.2 of the pipeline-stage-step-plugin (see changelog).

It seems that stages can now be nested and they will appear in the view table, but I don't think it's what you're looking for.

这篇关于Jenkins Pipeline sh 显示名称/标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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