Amarula
Amarula

Reputation: 162

Get the list of artifacts from teamcity build and download only exact one

I am struggling to download only one artifact from lastsuccessful teamcity build.

Ofc, I can download all artifacts and then find one on my storage using http://teamcity/repository/downloadAll/buildTypeId/.lastSuccessful/ but it is a huge waste of time and traffic.

How can I get the list of artifacts in the lastSuccessful build? If I could get the list, then I would be able to form download request and get only the artifact I need.

i.e. my build has:

Suppose I need only Binaries.zip from that build, so if I am to find the list of artifacts, I would choose Binaries using regex(or whatever) and then create download link like so:

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

How can I do this?

Upvotes: 2

Views: 2586

Answers (2)

Amarula
Amarula

Reputation: 162

I think I've found solution. Here is the list of possible locators:

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]

specifying url using couple of them can provide one the arifacts list i.e. : http://teamcity/app/rest/builds/buildType:xxxx,state:finished/artifacts/

Upvotes: -1

JGooLaaR
JGooLaaR

Reputation: 94

TeamCity have api. Use it. List of artifacts:

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

In my case i have several folders in artifact directory, choosing one, getting list of files inside:

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

It looks like:

<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>

Then just make GET of:

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

And you will took file you need only, Thats all. :)

Upvotes: 4

Related Questions