如何仅获取先前 Jenkins 版本的全名

发布于 2025-01-12 13:44:26 字数 435 浏览 3 评论 0原文

我想发送使用以下命令收到的先前版本的全名:

Run previousBuild = steps.currentBuild.rawBuild.getPreviousBuildInProgress()

为了发送到 getItemByFullName,如下所示,

Jenkins.instance.getItemByFullName(previousBuildPath)

我尝试在 Run 类 hudson 文档中找到它,但没有成功。

在打印 previousBuild 时,我得到了带有内部版本号的名称,例如:

 previousBuild- > project_neme/build_name #100

但我只想获取没有字符串子字符串切割的名称。

I would like to send the full name of the previous build that was received by using the following:

Run previousBuild = steps.currentBuild.rawBuild.getPreviousBuildInProgress()

in order to send to getItemByFullName as you can see below,

Jenkins.instance.getItemByFullName(previousBuildPath)

I tried to find it in the Run class hudson Documentation with no success.

while printing previousBuild I got the name with the build number like:

 previousBuild- > project_neme/build_name #100

But I want to get only the name with no String substring cutting.

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

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

发布评论

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

评论(1

变身佩奇 2025-01-19 13:44:26

您正在寻找显示名称属性。显示名称是为每个构建指定的名称(如果您在执行期间更新它),后跟构建号。显示名称将仅返回构建名称。
Jenkins.instance.getItemByFullName('JobName').getLastBuild().displayName

阅读此处
https://javadoc.jenkins.io/hudson/model/Job.html

You are looking for display name property. Display name is the name given to each build (if you update it during execution) followed by a build number. The display name will only return the build name.
Jenkins.instance.getItemByFullName('JobName').getLastBuild().displayName

Read here
https://javadoc.jenkins.io/hudson/model/Job.html

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