How do you programatically download the artifacts

2019-09-07 06:43发布

问题:

I understand the HTTPClient and GET process. What I'm trying to find here is the correct URL/syntax to make this work with Team City.

I've been trying to get this to work using the examples at RestDocumentation

However, they all require a buildId. This is a distinct build number which changes with each build. I've tried several combinations with buildId=lastSuccesful but I just can't seem to get the syntax correct. I have been able to create a link that successfully downloads a specific build when pasted into a web browser, however, when I try to get it programatically, I get a 400 Unauthorized exception.

I'm thinking that before I can use the REST API, I need to somehow log in to Team City?

Anyway, this is probably quite a simple operation, I just don't seem to be able to decipher the steps to perform it.

So, here's the steps I think need to happen, but I have no Idea how to accomplish them.

  1. Programatically log into Team City. (This is now working for me)
  2. Get the BuildID of the last successfull build for my project. (HELP !!)
  3. Download the artifacts associated with the above build. (This is now working for me)

I would greatly appreciate any help in accomplishing the above.

Thanks !!

回答1:

Thank you Hackerman for getting me on the right track !!

So, if anybody is interested, here's the answer..

  1. Use guestAuth instead of httpAuth. This gives you authorization.
  2. Get the build number of the latest successful build. http://yourteamcityserver:8080/guestAuth/app/rest/buildTypes/id:yourprojectname/builds?count=1&status=SUCCESS

  3. Parse out the build number from the XML you receive back.

  4. Download your artifacts (specifying the file name of the artifact). http://yourteamcityserver:8080/guestAuth/app/rest/builds/id:theIDthatYOUparsedINstep3/artifacts/yourartifactname.zip

Hope this saves some of you the hours I spent figuring out how this all works.

Thanks again Hackerman !!!!