public SCMRevision GetVersion() { BuildsRootObject builds = this.GetBuilds(); if (builds == null || builds.count == 0) { return(null); } BuildRootObject build = GetBuild(builds.build[0]); ChangeRootObject change = GetChange(build); if (change.count == 0)// no changes --> trail for build with changes { bool changesFound = false; for (int i = 1; i < builds.build.Count; i++) { build = GetBuild(builds.build[i]); change = GetChange(build); if (change.count > 0) { changesFound = true; break; } } if (!changesFound) { return new SCMRevision { Revision = build.revisions.revision[0].version } } ; } ChangesRootObject changes = GetChanges(change); DateTime at = DateTime.ParseExact(changes.date, "yyyyMMddTHHmmsszzzz", System.Globalization.CultureInfo.InvariantCulture); SCMRevision ver = new SCMRevision { Commiter = changes.username, CommitMessage = changes.comment, CommitTime = at, CreateAt = at, Revision = changes.version }; return(ver); }
private ChangesRootObject GetChanges(TeamCity.ChangeRootObject id) { try { using (ServiceStack.JsonServiceClient client = new ServiceStack.JsonServiceClient(parameters.Host)) { client.SetCredentials(parameters.User, parameters.Password); client.AlwaysSendBasicAuthHeader = true; ChangesRootObject b = client.Get <ChangesRootObject>(id.change[0].href); return(b); } } catch (Exception e) { logger.Exception(e, "GetChanges", ""); return(null); } }