public async static Task ScheduleJob(string jobUrl, string jenkinsServerUrl)
 {
     using (WebClient client = JenkinsDataLoader.CreateJenkinsWebClient(jenkinsServerUrl))
     {
         Uri    buildUri = CreateBuildUri(jobUrl);
         byte[] response = await client.UploadValuesTaskAsync(buildUri, new NameValueCollection());
     }
 }
        public async static Task DequeueJob(JenkinsQueueItem queueItem, string jenkinsServerUrl)
        {
            if (queueItem == null)
            {
                throw new ArgumentNullException("queueItem");
            }

            Uri dequeueUri = CreateDeqeueuBuildUri(jenkinsServerUrl, queueItem);

            using (WebClient client = JenkinsDataLoader.CreateJenkinsWebClient(jenkinsServerUrl))
            {
                byte[] response = await client.UploadValuesTaskAsync(dequeueUri, new NameValueCollection());
            }
        }
        public async static Task CancelBuild(JenkinsJob job, string jenkinsServerUrl)
        {
            if (job == null)
            {
                throw new ArgumentNullException("job");
            }

            Uri cancelBuildUri = CreateCancelBuildUri(job);

            if (cancelBuildUri != null)
            {
                using (WebClient client = JenkinsDataLoader.CreateJenkinsWebClient(jenkinsServerUrl))
                {
                    byte[] response = await client.UploadValuesTaskAsync(cancelBuildUri, new NameValueCollection());
                }
            }
        }
Beispiel #4
0
 public static async Task BuildJobWithDefaultParameters(JenkinsJob job, string jenkinsServerUrl)
 {
     using (var client = JenkinsDataLoader.CreateJenkinsWebClient(jenkinsServerUrl))
     {
         Uri buildUri = CreateBuildWithParametersUri(job.Url);
         var parametersNameValueCollection = new NameValueCollection();
         job.Property.Aggregate(parametersNameValueCollection, (collection, property) =>
         {
             if (property.ParameterDefinitions != null && property.ParameterDefinitions.Any())
             {
                 property.ParameterDefinitions.ToList().ForEach(pd => collection.Add(pd.Name, pd.DefaultParameterValue.Value));
             }
             return(collection);
         });
         parametersNameValueCollection.Add("delay", "0sec");
         byte[] response = await client.UploadValuesTaskAsync(buildUri, parametersNameValueCollection);
     }
 }
        public async static Task <string> GetLatestLog(string jobUrl, JenkinsServer jenkinsServer)
        {
            string logData = null;

            using (WebClient client = JenkinsDataLoader.CreateJenkinsWebClient(jenkinsServer))
            {
                var latestLogUri = CreateLatestLogUri(jobUrl);
                logData = await client.DownloadStringTaskAsync(latestLogUri);
            }

            string fileName = null;

            if (!string.IsNullOrWhiteSpace(logData))
            {
                fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".txt";
                File.WriteAllText(fileName, logData);
            }

            return(fileName);
        }