如何从 TeamCity 提取工件?

发布于 2024-07-08 03:46:38 字数 1089 浏览 9 评论 0原文

我想从 teamcity 中提取工件。

我一直在尝试使用 c# 和 HtmlAgilityPack 访问网站并查找最新版本及其工件。 我目前陷入登录困境,我想我只需要发送会话 Cookie 即可。

我的方向正确吗,还有其他人尝试过吗?

我意识到使用构建脚本推送文件很容易,但我想尽量减少对 Ant、NAnt 文件的更改,因为我正在考虑将其扩展到 100 个应用程序。

编辑:这个问题看起来很有希望从登录后面的页面

编辑:现在可以使用,我只需要编写一些代码来解析它

WebClient ww = new WebClient();
ww.Credentials = CredentialCache.DefaultCredentials;
ww.DownloadString("http://yourteamcity.com/login.html");
ww.Headers.Add("Cookie",ww.ResponseHeaders["Set-Cookie"]);

NameValueCollection post = new NameValueCollection();
post.Add("username", "name");
post.Add("remember","true");
post.Add("submitLogin", "Login");
post.Add("publicKey","long thing to intercept with fiddler");
post.Add("encryptedPassword","not giving you this");
post.Add("_", "");
byte[] values = ww.UploadValues("http://yourteamcity.com/loginSubmit.html", "POST",post);
string s = ww.DownloadString("http://yourteamcity.com/overview.html");

I would like to pull artifacts from teamcity.

I've been trying to use c# and the HtmlAgilityPack to goto the website and find the latest version and its artifacts. I'm currently stuck at the login, I think I just need to be sending Session Cookies out.

Am I going in the right direction, has anyone else tried this?

I realize that pushing files out with the build scripts is easy but I'd like to minimize changes to the Ant,NAnt files since I'm looking at scaling this to 100 apps.

Edit: this question looks promising Getting HTML from a page behind a login

Edit: this works now, I just need to write some code to parse it

WebClient ww = new WebClient();
ww.Credentials = CredentialCache.DefaultCredentials;
ww.DownloadString("http://yourteamcity.com/login.html");
ww.Headers.Add("Cookie",ww.ResponseHeaders["Set-Cookie"]);

NameValueCollection post = new NameValueCollection();
post.Add("username", "name");
post.Add("remember","true");
post.Add("submitLogin", "Login");
post.Add("publicKey","long thing to intercept with fiddler");
post.Add("encryptedPassword","not giving you this");
post.Add("_", "");
byte[] values = ww.UploadValues("http://yourteamcity.com/loginSubmit.html", "POST",post);
string s = ww.DownloadString("http://yourteamcity.com/overview.html");

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文