从 teamcity build 中获取工件列表并只下载一个
Get the list of artifacts from teamcity build and download only exact one
我很难从 lastsuccessful
teamcity build 下载一个工件。
Ofc,我可以下载所有工件,然后使用以下命令在我的存储中找到一个
http://teamcity/repository/downloadAll/buildTypeId/.lastSuccessful/
但这是对时间和流量的巨大浪费。
如何获取 lastSuccessful
构建中的工件列表?
如果我能得到列表,那么我就能够形成下载请求并只得到我需要的工件。
即我的构建有:
- 安装软件..buildId.zip
- 库..buildId.zip
- 二进制文件..buildId.zip
假设我只需要那个版本的Binaries.zip,所以如果我要找到工件列表,我会选择使用正则表达式(或其他)的二进制文件,然后像这样创建下载link :
http://teamcity/repository/download/#buildTypeId#/#buildId#/binaries<..>.zip
我该怎么做?
TeamCity 有 api。用它。
工件列表:
http://teamcity:8008/httpAuth/app/rest/builds/id:75105/artifacts
在我的例子中,我在 artifact 目录中有几个文件夹,选择一个,获取里面的文件列表:
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
你只会拿走你需要的文件,仅此而已。 :)
我想我找到了解决办法。
以下是可能的定位器列表:
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/
我很难从 lastsuccessful
teamcity build 下载一个工件。
Ofc,我可以下载所有工件,然后使用以下命令在我的存储中找到一个 http://teamcity/repository/downloadAll/buildTypeId/.lastSuccessful/ 但这是对时间和流量的巨大浪费。
如何获取 lastSuccessful
构建中的工件列表?
如果我能得到列表,那么我就能够形成下载请求并只得到我需要的工件。
即我的构建有:
- 安装软件..buildId.zip
- 库..buildId.zip
- 二进制文件..buildId.zip
假设我只需要那个版本的Binaries.zip,所以如果我要找到工件列表,我会选择使用正则表达式(或其他)的二进制文件,然后像这样创建下载link :
http://teamcity/repository/download/#buildTypeId#/#buildId#/binaries<..>.zip
我该怎么做?
TeamCity 有 api。用它。 工件列表:
http://teamcity:8008/httpAuth/app/rest/builds/id:75105/artifacts
在我的例子中,我在 artifact 目录中有几个文件夹,选择一个,获取里面的文件列表:
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
你只会拿走你需要的文件,仅此而已。 :)
我想我找到了解决办法。 以下是可能的定位器列表:
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/