How does one get all the artifacts as a zip using TeamCity Rest API?
Asked Answered
S

3

7

The Docs show this

/repository/downloadAll/BUILD_TYPE_ID/BUILD_SPECIFICATION

for getting all of your artifacts as a zip file, but that isn't using the REST API. Is there a way in the REST API do do the same thing? The Docs seem to indicate that the repository links are only there for backwards compatibility.

Strade answered 4/1, 2013 at 20:24 Comment(0)
I
6

You can use this URL, it works for me:

http://<TeamcityUrl>/httpAuth/app/rest/builds/id:<BuildId>/artifacts/archived

I use TeamCity 9.

Isotron answered 15/7, 2016 at 8:14 Comment(1)
Thank you, because download all button in UI doesn't work correctly (downloads 1 folder), while your link works correctly.Cornelia
K
1

From the documentation: http://confluence.jetbrains.net/display/TW/REST+API+Plugin#RESTAPIPlugin-buildartifacts

Artifacts:
GET <TeamcityUrl>/httpAuth/app/rest/builds/<buildLocator>/artifacts/files/<artifact relative name>

If you download the artifacts from within a TeamCity build, consider using teamcity.auth.userId/teamcity.auth.password system properties as credentials for the download artifacts request: this way TeamCity will have a way to record that one build used artifacts of another and will display that on build's Dependencies tab.

have you tried this?

Kirstiekirstin answered 7/1, 2013 at 9:55 Comment(1)
yes. this gets individual build items 1 by 1. I can use the old "downloadAll" link in my question to get a single ZIP of the entire set of artifcats. I was looking for the REST API to do the same thing.Strade
C
1

I'm not sure it's documented, but it works.

http://teamcity-url/downloadArtifacts.html?buildId=216886

If you are using it from .NET you may use the following code:

List<string> downloadedFiles = new RemoteTc()
     .Connect(a => a.ToHost("tc").AsGuest())
     .DownloadArtifacts(123, @"C:\DownloadedArtifacts");

The above code uses FluentTc library

Crystallography answered 20/6, 2016 at 20:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.