Esempio n. 1
0
        public Job.Job CreateJob(
            string name,
            string config_xml)
        {
            Trace.TraceInformation("Creating job: {0} with Config xml: {2}{1}{2}",
                                   name,
                                   config_xml,
                                   Environment.NewLine);

            Login();
            Job.Job jobinfo = null; // GetJobInfo(name);
            if (jobinfo == null)
            {
                Cookie session_id = AuthCookies.GetCookies(new Uri(ServerUrl)).Cast <Cookie>().First(x => x.Name == "_session_id");
                string response   = SendPostRequest(
                    ServerUrl + String.Format(Queries.CREATE_JOB, HttpUtility.UrlEncode(name)),
                    String.Format("data={0}&_session_id={1}", HttpUtility.UrlEncode(config_xml), HttpUtility.UrlEncode(session_id.Value)),
                    "application/x-www-form-urlencoded");
                //Console.WriteLine(response);
                if (response != null)
                {
                    jobinfo = GetJobInfo(name);
                }
            }
            return(jobinfo);
        }
Esempio n. 2
0
        private Dictionary <string, object> AppendSessionId(Dictionary <string, object> query)
        {
            this.Login();

            if (query == null)
            {
                query = new Dictionary <string, object>();
            }

            Cookie session_id = AuthCookies.GetCookies(new Uri(ServerUrl)).Cast <Cookie>().First(x => x.Name == "_session_id");

            query["_session_id"] = session_id.Value;
            return(query);
        }
Esempio n. 3
0
        public string BuildJob(
            string name,
            string swiftFilename,
            string buildQuery = "")
        {
            Login();

            Cookie session_id = AuthCookies.GetCookies(new Uri(ServerUrl)).Cast <Cookie>().First(x => x.Name == "_session_id");
            string response   = SendPostRequest(
                ServerUrl + String.Format(Queries.BUILD_JOB, name, HttpUtility.UrlEncode(swiftFilename), buildQuery),
                String.Format("_session_id={0}", HttpUtility.UrlEncode(session_id.Value)),
                "application/x-www-form-urlencoded");

            return(response);
        }
Esempio n. 4
0
        /// <summary>
        /// Stops the last build on the server
        /// </summary>
        /// <param name="name">Name of the job</param>
        public void StopJob(string name)
        {
            Login();
            var jobinfo = GetJobInfo(name);

            if (jobinfo != null)
            {
                Cookie session_id = AuthCookies.GetCookies(new Uri(ServerUrl)).Cast <Cookie>().First(x => x.Name == "_session_id");
                string response   = SendPostRequest(
                    ServerUrl + String.Format(String.Format(Queries.STOP_JOB, HttpUtility.UrlEncode(name))),
                    String.Format("_session_id={0}", HttpUtility.UrlEncode(session_id.Value)),
                    "application/x-www-form-urlencoded");
                //Console.WriteLine(response);
            }
        }