Skip to content

Instantly share code, notes, and snippets.

@dotob
Created November 7, 2012 21:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dotob/4034731 to your computer and use it in GitHub Desktop.
Save dotob/4034731 to your computer and use it in GitHub Desktop.
teamcity sample artifact vs. buildinfo
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;
}
@maxmanuylov
Copy link

Hi!

I'm Maxim Manuylov from Oredev.

We have an issue in our tracker about listing build artifacts via REST: TW-20830 - can it help you? If yes, please vote for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment