Example #1
0
        public BuildArtifacts GetArtifacts()
        {
            BuildsRootObject builds = this.GetBuilds();

            if (builds == null || builds.count == 0)
            {
                return(null);
            }

            BuildRootObject     build = this.GetBuild(builds.build[0]);
            ArtifcatsRootObject arts  = this.GetArtifact(build);

            for (int i = 0; i < arts.files.Count; i++)
            {
                if (arts.files[i].name.Equals(parameters.ArtifactName, StringComparison.InvariantCultureIgnoreCase))
                {
                    using (System.Net.WebClient cl = new System.Net.WebClient())
                    {
                        Uri uri = new Uri(new Uri(parameters.Host), arts.files[i].content.href);
                        cl.Headers.Add("Authorization", "Basic " +
                                       Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", parameters.User, parameters.Password))));
                        byte[]         zip    = cl.DownloadData(uri);
                        BuildArtifacts result = BuildArtifacts.FromZipArchive(parameters.AssemblyFileName, build.revisions.revision[0].version, zip);

                        return(result);
                    }
                }
            }
            return(null);
        }
Example #2
0
        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);
        }
Example #3
0
 private BuildsRootObject GetBuilds()
 {
     try
     {
         using (ServiceStack.JsonServiceClient client = new ServiceStack.JsonServiceClient(parameters.Host))
         {
             client.SetCredentials(parameters.User, parameters.Password);
             client.AlwaysSendBasicAuthHeader = true;
             BuildsRootObject b = client.Get <BuildsRootObject>(new BuildsRequest
             {
                 buildType = parameters.BuildType,
                 status    = "SUCCESS"
             });
             return(b);
         }
     }
     catch (Exception e)
     {
         logger.Exception(e, "GetBuilds", "");
         return(null);
     }
 }