Exemplo n.º 1
0
        public static JenkinsBuild GetLatestBuild(string baseUri, string versionBase, bool stable = true)
        {
            JenkinsBuild result = null;

            if (!(baseUri.EndsWith("/")))
            {
                baseUri = baseUri + "/";
            }

            // http://jenkins.mumech.com/job/MechJeb2/lastStableBuild/api/json
            string  json  = Call(baseUri + "lastStableBuild/api/json");
            JObject build = JObject.Parse(json);

            if (build != null)
            {
                string buildNumber = (string)build ["number"];

                JArray artifacts = (JArray)build ["artifacts"];
                log.DebugFormat("  Parsing artifacts from {0}", artifacts);
                foreach (JObject artifact in artifacts.Children())
                {
                    log.DebugFormat("    Parsing artifact from {0}", artifact);

                    string fileName = (string)artifact ["fileName"];

                    // TODO - filtering of artifacts, for now hardcoded for zip files.
                    if (fileName.EndsWith(".zip"))
                    {
                        result = new JenkinsBuild(artifact, versionBase, buildNumber, baseUri, stable);
                    }
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public static JenkinsBuild GetLatestBuild(string baseUri, string versionBase, bool stable = true)
        {
            JenkinsBuild result = null;
            if (!(baseUri.EndsWith ("/")))
            {
                baseUri = baseUri + "/";
            }

            // http://jenkins.mumech.com/job/MechJeb2/lastStableBuild/api/json
            string json = Call (baseUri + "lastStableBuild/api/json");
            JObject build = JObject.Parse (json);
            if (build != null)
            {
                string buildNumber = (string) build ["number"];

                JArray artifacts = (JArray) build ["artifacts"];
                log.DebugFormat("  Parsing artifacts from {0}", artifacts);
                foreach (JObject artifact in artifacts.Children())
                {
                    log.DebugFormat("    Parsing artifact from {0}", artifact);

                    string fileName = (string) artifact ["fileName"];

                    // TODO - filtering of artifacts, for now hardcoded for zip files.
                    if (fileName.EndsWith (".zip"))
                    {
                        result = new JenkinsBuild (artifact, versionBase, buildNumber, baseUri, stable);
                    }
                }
            }

            return result;
        }
Exemplo n.º 3
0
        public IEnumerable <JenkinsBuild> GetAllBuilds(JenkinsRef reference, JenkinsOptions options)
        {
            if (options == null)
            {
                options = new JenkinsOptions();
            }
            string  url       = Regex.Replace(reference.BaseUri.ToString(), @"/$", "");
            JObject job       = Call <JObject>($"{url}/api/json");
            JArray  builds    = (JArray)job["builds"];
            string  resultVal = null;

            BuildTypeToResult.TryGetValue(options.BuildType, out resultVal);
            foreach (JObject buildEntry in builds)
            {
                Log.Info($"Processing {buildEntry["url"]}");
                JenkinsBuild build = Call <JenkinsBuild>($"{buildEntry["url"]}api/json");
                // Make sure build status matches options.BuildType
                if (resultVal == null || build.Result == resultVal)
                {
                    yield return(build);
                }
            }
        }