如何使用管道在jenkins中检索与构建关联的工作项? [英] How to retrieve work items associated to a build in jenkins with pipeline?

查看:49
本文介绍了如何使用管道在jenkins中检索与构建关联的工作项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在jenkins管道中触发构建时,我使用build.changeSets变量来检索要通过电子邮件发送的所有更改,如下所示:

When i trigger a build in jenkins pipeline i use build.changeSets variable to retrieve all the changes to send by email like this:

  def changeSets = build.changeSets
  if(changeSets != null) {
    def hadChanges = false %>
  <table class="section">
    <tr class="tr-title">
      <td class="td-title" colspan="2">Cambios</td>
    </tr>
    <% changeSets.each() { 
      cs_list -> cs_list.each() { 
        cs -> hadChanges = true %>
    <tr>
        <td class="td-subtitle">Usuario:</td>
        <td class="td-author">
        <%= cs.metaClass.hasProperty('commitId') ? cs.commitId : cs.metaClass.hasProperty('revision') ? cs.revision : cs.metaClass.hasProperty('changeNumber') ? cs.changeNumber : "" %>
        <B><%= cs.author %></B>
        </td>
    </tr>

但是我不知道如何检索与此更改相关的工作项,我该怎么做?

but i dont know ho to retrive the workitems associated to this changes, how can i do it?

推荐答案

如果您已将TFS用作源代码管理器并使用Jenkins进行构建(因为已检索到变更集),则可以使用 TFS变更集REST获取工作项API :

If you are using TFS as the Source Code Manager and build with Jenkins, as you have already retrieved the changesets, then you can get the workitems with the TFS changeset REST API:

GET http://SERVER:8080/tfs/Collection/_apis/tfvc/changesets/{changesetID}/workItems

您还可以尝试使用Jenkins REST API来检索构建详细信息. (每页右下角都有一个REST API链接,请尝试导航到特定的内部版本,然后使用REST API来检查内部版本信息.)

You can also have a try with the Jenkins REST API to retrieve the build details. (There is a REST API link in the bottom right of each page, jus try to navigate to a specific build, then check the build info with the REST API).

还可以查看下面的文章,这可能会有所帮助(最后一部分):

Also check below article, it may helps (The last part):

查看全文

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