【问题标题】:Get the list of artifacts from teamcity build and download only exact one从 teamcity 构建中获取工件列表并仅下载准确的一个
【发布时间】:2017-04-06 12:05:14
【问题描述】:

我很难从lastsuccessful teamcity build 下载一个工件。

Ofc,我可以下载所有工件,然后使用 http://teamcity/repository/downloadAll/buildTypeId/.lastSuccessful/ 但这是对时间和交通的巨大浪费。

如何获取 lastSuccessful 构建中的工件列表? 如果我能得到这个列表,那么我就能形成下载请求并只得到我需要的工件。

即我的构建有:

  • SetupSoft..buildId.zip
  • Libs..buildId.zip
  • 二进制文件..buildId.zip

假设我只需要该构建中的 Binaries.zip,所以如果我要查找工件列表,我会选择使用正则表达式(或其他)的二进制文件,然后像这样创建下载链接:

http://teamcity/repository/download/#buildTypeId#/#buildId#/binaries<..>.zip

我该怎么做?

【问题讨论】:

    标签: perl rest teamcity


    【解决方案1】:

    TeamCity 有 api。用它。 工件列表:

    http://teamcity:8008/httpAuth/app/rest/builds/id:75105/artifacts
    

    在我的情况下,我在工件目录中有几个文件夹,选择一个,获取里面的文件列表:

    http://teamcity:8008/httpAuth/app/rest/builds/id:75105/artifacts/children/Scripts
    

    看起来像:

    <files count="1">
    <file name="000-201704070732-000000-00000-0160609.07.Build-0088.01.Schema.sql" size="88340" modificationTime="20170407T074931+0300" href="/httpAuth/app/rest/builds/id:75105/artifacts/metadata/Scripts/000-201704070732-000000-00000-0160609.07.Build-0088.01.Schema.sql">
    <content href="/httpAuth/app/rest/builds/id:75105/artifacts/content/Scripts/000-201704070732-000000-00000-0160609.07.Build-0088.01.Schema.sql"/>
    </file>
    </files>
    

    然后只需获取:

    http://teamcity:8008/httpAuth/app/rest/builds/id:75105/artifacts/content/Scripts/000-201704070732-000000-00000-0160609.07.Build-0088.01.Schema.sql
    

    你只需要你需要的文件,仅此而已。 :)

    【讨论】:

    • 这一切都很好,但我不知道你在链接中提到的构建 ID (id:75105),我所拥有的只是构建类型 ID(它是字符串值),我只需要最后一个成功构建。在这种情况下,我如何设法获得工件?我试过使用'buildTypeId=mybtt',但它是被禁止的:无效的单个值:'buildTypeId=mybtt'。应该是一个数字。
    • @Amarula 你可以这样做:$APIURL = "${API_BaseUrl}/httpAuth/app/rest/builds/?locator=buildType:${API_BuildType},state:finished,count:1" 获得前 1 个成功构建的简单方法。然后,您获得“ID”
    【解决方案2】:

    我想我找到了解决办法。 以下是可能的定位器列表:

    Supported dimensions are: [id, taskId, project, affectedProject, buildType, branch, 
    agent, user, personal,  state, tag, property, compatibleAgent, number, status, canceled, 
    pinned, queuedDate, startDate, finishDate, sinceBuild, sinceDate, untilBuild,   untilDate, 
    failedToStart, snapshotDependency, 
    artifactDependency, hanging, history, defaultFilter, $singleValue, start, lookupLimit]
    

    使用其中几个来指定 url 可以提供一个 arifacts 列表,即: http://teamcity/app/rest/builds/buildType:xxxx,state:finished/artifacts/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-23
      • 2012-12-10
      • 1970-01-01
      • 2021-06-14
      • 1970-01-01
      相关资源
      最近更新 更多