How do you programatically download the artifacts from the latest Team City build using C#?

♀尐吖头ヾ 提交于 2020-01-07 06:53:10

问题


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



来源:https://stackoverflow.com/questions/40664603/how-do-you-programatically-download-the-artifacts-from-the-latest-team-city-buil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!