Created
November 7, 2012 21:51
-
-
Save dotob/4034731 to your computer and use it in GitHub Desktop.
Revisions
-
dotob created this gist
Nov 7, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ private Uri CreateArtefactUri(Build build) { string finalArtifactName = string.Empty; try { string artifactInfoUriString = string.Format("http://{0}/guestAuth/repository/download/{1}/{2}/teamcity-ivy.xml", this.teamCityHost, this.buildType, build.Number); using (WebClient wc = new WebClient()) { var artefactInfo = wc.DownloadString(artifactInfoUriString); XDocument artifactInfoXmlDoc = XDocument.Parse(artefactInfo); foreach (var artifactElement in artifactInfoXmlDoc.Element("ivy-module").Element("publications").Elements("artifact").Where(e => e.Attribute("ext").Value == "exe")) { var artifactName = artifactElement.Attribute("name").Value; if (Regex.IsMatch(artifactName, this.artifactNameMatch)) { finalArtifactName = artifactName; } } } } catch (Exception exception) { nlogger.Error("error while CreateArtefactUri for build: {0}, {1}", build, exception); } string artifactDownLoadUriString = string.Format("http://{0}/guestAuth/repository/download/{1}/{2}/{3}.exe", this.teamCityHost, this.buildType, build.Number, finalArtifactName); var artifactDownLoadUri = new Uri(artifactDownLoadUriString); return artifactDownLoadUri; }