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

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

问题描述

借助Jenkins 2 Pipeline插件,它具有一项有用的功能,可以快速概述管道阶段和步骤状态,包括记录输出.

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 Script"(如下图所示).

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的答案,现在可以他的回答以获取详细信息和评论!

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脚本步骤(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", name: "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"

但是,它已作为旧版允许阶段复制的副本关闭 用作标记的区块,该区块最近已修复,并且 似乎包含在管道阶段步骤的 v2.2中-plugin(请参阅 更新日志).

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

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天全站免登陆