private QueuedBuild queueBuild(BuildDefinition b, string branch) { bool success = false; QueuedBuild queuedB = new QueuedBuild(); if (String.IsNullOrWhiteSpace(branch)) { if(b.Repository != null) { branch = b.Repository.DefaultBranch == null?"": b.Repository.DefaultBranch; } } success = VSTSService.QueueBuild(b.Id, branch, "", out queuedB); return queuedB; }
private async void showQueueBuildContentDialog(BuildDefinition b) { QueuedBuild qb = new QueuedBuild(); if (b == null) return; QueueBuildCB.DataContext = b; QueueBuildCB.HorizontalAlignment = HorizontalAlignment.Center; QueueBuildCB.VerticalAlignment = VerticalAlignment.Center; var result = await QueueBuildCB.ShowAsync(); if (result == ContentDialogResult.Primary) { qb = queueBuild(b, ""); if (!String.IsNullOrWhiteSpace(qb.BuildNumber)) { Utility.ShowToastMessage("Build queued successfully!", qb.BuildNumber); ifRefresh = true; } else { Utility.ShowToastMessage("Failed to queue build.", "Please retry later..."); } } }
private QueuedBuild queueBuild(Build b, string branch) { bool success = false; QueuedBuild queuedB = new QueuedBuild(); if(String.IsNullOrWhiteSpace(branch) ) { branch = b.SourceBranch; } if (b.Definition != null) { success = VSTSService.QueueBuild(b.Definition.Id, branch, "", out queuedB); } return queuedB; }
private QueuedBuild queueBuild() { bool success = false; string branch = build.SourceBranch; QueuedBuild queuedB = new QueuedBuild(); if (String.IsNullOrWhiteSpace(branch)) { branch = build.SourceBranch == null ? "" : build.SourceBranch; } success = VSTSService.QueueBuild(build.Definition.Id, branch, "", out queuedB); return queuedB; }
private static QueuedBuild getQueuedBuildFromJson(dynamic qb) { QueuedBuild build = new QueuedBuild { Id = qb.id, BuildNumber = qb.buildNumber, DefinitionName = qb.definition.name, Url = qb.url, QueuedDate = qb.queueTime, RequestedForName = qb.requestedFor.displayName, RequestedForUName = qb.requestedFor.uniqueName, Priotiy = qb.priority, Controller = qb.queue.name, Status = qb.status, SourceBranch = qb.sourceBranch }; return build; }
internal static bool QueueBuild(string buildDefId, string branch, string description, out QueuedBuild newBuild) { bool success = true; var query = string.Format(Constants.API_POST_BUILD_QUEUE_A_BUILD_URL, LoginContext.GetLoginContext().VSTSAccountUrl, ProjectContext.GetProjectContext().Project); var jsonDataForPostCall = string.Format(Constants.API_POST_BODY_BUILD_QUEUE_A_BUILD_JSON_BODY, buildDefId, branch); try { var requestPostData = new StringContent(jsonDataForPostCall, Encoding.UTF8, "application/json"); var responseBody = LoginService.VSTSHttpClient.PostAsync(new Uri(query), requestPostData).Result; responseBody.EnsureSuccessStatusCode(); var responseWit = responseBody.Content.ReadAsStringAsync().Result; dynamic json = JsonConvert.DeserializeObject(responseWit); newBuild = getQueuedBuildFromJson(json); } catch { success = false; newBuild = new QueuedBuild(); } return success; }