如何仅获取先前 Jenkins 版本的全名
我想发送使用以下命令收到的先前版本的全名:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在寻找显示名称属性。显示名称是为每个构建指定的名称(如果您在执行期间更新它),后跟构建号。显示名称将仅返回构建名称。
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