Skip to content

Instantly share code, notes, and snippets.

@dotob
Created November 7, 2012 21:51
Show Gist options
  • Save dotob/4034731 to your computer and use it in GitHub Desktop.
Save dotob/4034731 to your computer and use it in GitHub Desktop.

Revisions

  1. dotob created this gist Nov 7, 2012.
    22 changes: 22 additions & 0 deletions gistfile1.cs
    Original 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;
    }