Esempio n. 1
0
        private TravisCiBuildStatus GetBuildStatus(BuildDefinitionSetting buildDefinitionSetting)
        {
            var webClient          = new WebClient();
            var travisBuildDef     = TravisCiBuildDefinition.FromIdString(buildDefinitionSetting.Id);
            var buildDefinitionUrl = "https://api.travis-ci.org/repositories/" + travisBuildDef.OwnerName + "/" + travisBuildDef.ProjectName + ".json";

            try
            {
                var json        = webClient.DownloadString(buildDefinitionUrl);
                var lastBuildId = GetJsonValue(json, "last_build_id");
                var buildUrl    = "https://api.travis-ci.org/builds/" + lastBuildId + ".json";
                json = webClient.DownloadString(buildUrl);
                return(new TravisCiBuildStatus(travisBuildDef, json, buildDefinitionSetting));
            }
            catch (WebException webException)
            {
                throw WebClientXml.ToServerUnavailableException(buildDefinitionUrl, webException);
            }
        }
Esempio n. 2
0
        private TravisCiBuildStatus GetBuildStatus(CiEntryPointSetting ciEntryPointSetting, BuildDefinitionSetting buildDefinitionSetting)
        {
            var webClient = new WebClient();
            var authToken = ciEntryPointSetting.GetPassword();

            AddTravisHeaders(webClient, authToken);
            var travisBuildDef     = TravisCiBuildDefinition.FromIdString(buildDefinitionSetting.Id);
            var buildDefinitionUrl = GetUrl(ciEntryPointSetting.Url, travisBuildDef.OwnerName, travisBuildDef.ProjectName);

            try
            {
                var json        = webClient.DownloadString(buildDefinitionUrl);
                var lastBuildId = GetJsonValue(json, "last_build_id");
                var buildUrl    = string.Format("{0}builds/{1}", ciEntryPointSetting.Url, lastBuildId);
                json = webClient.DownloadString(buildUrl);
                return(new TravisCiBuildStatus(travisBuildDef, json, buildDefinitionSetting));
            }
            catch (WebException webException)
            {
                throw WebClientXml.ToServerUnavailableException(buildDefinitionUrl, webException);
            }
        }