public void ChangeBuildStatus(BuildStatus buildStatus) { m_TeamCityWriter.WriteRawMessage(new ServiceMessage("buildStatus") { { "status", buildStatus.ToString().ToUpper() } }); }
/// <summary> /// Returns a <see cref="System.String"/> that represents the specified <see cref="BuildStatus"/>. /// </summary> /// <inheritdoc/> public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { BuildStatus status = (BuildStatus)value; switch (status) { case BuildStatus.InProgress: return("In Progress"); case BuildStatus.NotStarted: return("Not Started"); case BuildStatus.PartiallySucceeded: return("Partially Succeeded"); case BuildStatus.Loading: return("Loading..."); case BuildStatus.NoneFound: return("No build(s) found."); default: return(status.ToString()); } }
public void By_Status(BuildStatus status) { // Arrange var locator = By.Build.Status(status); // Act var query = (locator as ILocator).GetLocatorQueryString(); // Assert query.Should().Be($"status:{status.ToString().ToUpper()}"); }
public async Task <List <Lib.Build> > GetWithStatus(BuildStatus statusFilter, BuildProviderSettings buildProviderSettings) { try { var excludedBuildDefinitionIds = buildProviderSettings.ExcludedBuildDefinitionIds ?? new List <long>(); var urls = _urlBuilder.Build(buildProviderSettings.Instance, buildProviderSettings.Collection, buildProviderSettings.TeamProjects); var responses = new List <BuildDefinitionsResponse>(); foreach (var tfsUrl in urls) { var request = tfsUrl .WithBasicAuth(buildProviderSettings.AccessToken, string.Empty) .AppendPathSegment("build") .AppendPathSegment("builds") .SetQueryParam("statusFilter", statusFilter.ToString()) .SetQueryParam("maxBuildsPerDefinition", 1) .SetQueryParam("queryOrder", "finishTimeDescending"); _logger.Information($"Getting build definitions from url {request.Url}"); var res = await request.GetAsync(); var response = await request.GetJsonAsync <BuildDefinitionsResponse>(); responses.Add(response); } return(responses .SelectMany(response => response .Builds .Where(bd => !excludedBuildDefinitionIds.Contains(bd.Id)) .Select(_mapper.Map <Build, Lib.Build>)) .ToList()); } catch (FlurlHttpTimeoutException) { // FlurlHttpTimeoutException derives from FlurlHttpException; catch here only // if you want to handle timeouts as a special case _logger.Error("Request timed out."); } catch (FlurlHttpException ex) { // ex.Message contains rich details, inclulding the URL, verb, response status, // and request and response bodies (if available) _logger.Error($"Calling {ex.Call.FlurlRequest.Url} returned the following error:"); _logger.Error(ex.Message); _logger.Error($"Status code: {ex.Call.HttpStatus.ToString()}"); _logger.Error($"Request Body: {ex.Call.RequestBody}"); _logger.Error($"Response Body: {await ex.GetResponseStringAsync()}"); } return(new List <Lib.Build>()); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { BuildStatus status = (BuildStatus)value; string text; switch (status) { case BuildStatus.Success: text = "Successful"; break; case BuildStatus.SuccessAndBuilding: text = "Successful and building"; break; case BuildStatus.Failed: text = "Failed"; break; case BuildStatus.FailedAndBuilding: text = "Failed and building"; break; case BuildStatus.Aborted: text = "Aborted"; break; case BuildStatus.Disabled: text = "Disabled"; break; case BuildStatus.Unstable: text = "Unstable"; break; default: text = status.ToString(); break; } return(text); }
public override IList <string> ToMessage(Configuration.BotElement bot, Func <string, string> transform) { var formatter = new { TeamProjectCollection = transform(this.TeamProjectCollection), ProjectName = transform(this.ProjectName), BuildDefinition = transform(this.BuildDefinition), BuildStatus = transform(this.BuildStatus.ToString()), BuildUrl = this.BuildUrl, BuildNumber = transform(this.BuildNumber), BuildReason = transform(this.BuildReason.ToString()), RequestedFor = transform(this.RequestedFor), RequestedForDisplayName = transform(this.RequestedForDisplayName), DisplayName = transform(this.RequestedForDisplayName), StartTime = this.StartTime, FinishTime = this.FinishTime, UserName = transform(this.UserName), BuildDuration = FormatBuildDuration(bot), DropLocation = this.DropLocation }; return(new[] { bot.Text.BuildFormat.FormatWith(formatter), transform(BuildStatus.ToString()) }); }
public override IList <string> ToMessage(BotElement bot, TextElement text, Func <string, string> transform) { var formatter = new { TeamProjectCollection = transform(TeamProjectCollection), ProjectName = transform(ProjectName), BuildDefinition = transform(BuildDefinition), BuildStatus = transform(BuildStatus.ToString()), BuildUrl, BuildNumber = transform(BuildNumber), BuildReason = transform(BuildReason.ToString()), RequestedFor = transform(RequestedForUniqueName), RequestedForDisplayName = transform(RequestedForDisplayName), DisplayName = transform(RequestedForDisplayName), StartTime, FinishTime, UserName = transform(UserName), BuildDuration = FormatBuildDuration(text), DropLocation, MappedUser = bot.GetMappedUser(RequestedForUniqueName) }; return(new[] { GetBuildFormat(text).FormatWith(formatter), transform(BuildStatus.ToString()) }); }
public override IList <string> ToMessage(BotElement bot, Func <string, string> transform) { var formatter = new { TeamProjectCollection = transform(TeamProjectCollection), ProjectName = transform(ProjectName), BuildDefinition = transform(BuildDefinition), BuildStatus = transform(BuildStatus.ToString()), BuildUrl, BuildNumber = transform(BuildNumber), BuildReason = transform(BuildReason.ToString()), RequestedFor = transform(RequestedForUniqueName), RequestedForDisplayName = transform(RequestedForDisplayName), DisplayName = transform(RequestedForDisplayName), StartTime, FinishTime, UserName = transform(UserName), BuildDuration = FormatBuildDuration(bot), DropLocation, NewValue = NewValue == null ? bot.Text.BuildQualityNotSet : transform(NewValue), OldValue = OldValue == null ? bot.Text.BuildQualityNotSet : transform(OldValue), }; return(new[] { bot.Text.BuildQualityChangedFormat.FormatWith(formatter) }); }
public void ChangeBuildStatus(BuildStatus buildStatus) { m_TeamCityWriter.WriteRawMessage(new ServiceMessage("buildStatus") { {"status", buildStatus.ToString().ToUpper()} }); }
public IBuildHavingBuilder Status(BuildStatus buildStatus) { m_Having.Add("status:" + buildStatus.ToString().ToUpper()); return this; }
/// <summary> /// Update the status of a request /// </summary> /// <param name="projectName"></param> /// <param name="requestId"></param> /// <param name="newStatus"></param> /// <returns></returns> public async Task <string> UpdateBuildRequest(string projectName, int requestId, BuildStatus newStatus) { string response = await PatchResponse(string.Format("requests/{0}", requestId), new { status = newStatus.ToString() }, projectName, JSON_MEDIA_TYPE); return(response); }
public BuildLocator Status(BuildStatus buildStatus) { _locators.Add(new ApiLocator("status", buildStatus.ToString().ToUpper())); return(this); }
public IBuildHavingBuilder Status(BuildStatus buildStatus) { m_Having.Add("status:" + buildStatus.ToString().ToUpper()); return(this); }
private static async Task postaMessagetoSlack() { TFSBuildService bs = new TFSBuildService(tfsserverKey); List <BuildDefinition> buildsDefn; BuildDefinition psi = null;; BuildDefinition psv = null; BuildDefinition oc = null; buildsDefn = bs.GetAllbuildsOnServer(teamProjectName); foreach (var buildDefinition in buildsDefn) { if (buildDefinition.DefinitionName.Equals(psibuildName)) { psi = buildDefinition; } if (buildDefinition.DefinitionName.Equals(psvbuildName)) { psv = buildDefinition; } if (buildDefinition.DefinitionName.Equals(ocbuildName)) { oc = buildDefinition; } } BuildStatus psibuildStatus = BuildStatus.None; BuildStatus psvbuildStatus = BuildStatus.None; BuildStatus ocbuildStatus = BuildStatus.None; if (psi != null) { IBuildDetail[] bd = bs.GetLatestBuild(new BuildDefinition(psi.TeamProject, psi.DefinitionName)); if (bd != null && bd.Length > 0) { psibuildStatus = bs.GetLatestBuildStatusForProject(bd[0]); } } if (psv != null) { IBuildDetail[] bd = bs.GetLatestBuild(new BuildDefinition(psv.TeamProject, psv.DefinitionName)); if (bd != null && bd.Length > 0) { psvbuildStatus = bs.GetLatestBuildStatusForProject(bd[0]); } } if (oc != null) { IBuildDetail[] bd = bs.GetLatestBuild(new BuildDefinition(oc.TeamProject, oc.DefinitionName)); if (bd != null && bd.Length > 0) { ocbuildStatus = bs.GetLatestBuildStatusForProject(bd[0]); } } StringBuilder sb1 = new StringBuilder(); sb1.Append("Time:" + DateTime.Now); sb1.Append("\n"); sb1.Append("PSI status:"); sb1.Append(psibuildStatus.ToString()); sb1.Append("\n"); sb1.Append("PSV status:"); sb1.Append(psvbuildStatus.ToString()); sb1.Append("\n"); sb1.Append("OC status:"); sb1.Append(ocbuildStatus.ToString()); SlackClient client = new SlackClient(incomingwebhookurl); var response = await client.PostMessage(username : "******", text : sb1.ToString(), channel : "#localtfs"); var isValid = response.IsSuccessStatusCode ? "valid" : "invalid"; Console.WriteLine($"Received {isValid} response."); }
public IEnumerable <ChangeLogs.Project> GetProjectStatusList(BuildStatus status, int lookupLimit, int count, bool includeFiltered = false) { this._log.Info("Been asked to fetch a single change with id "); var toBuildChange = this._webRequestHelper.GetXmlWebRequestWithBasicAuth <ProjectList>( _configuration.ChangeProviderConfiguration.BaseUrl + "/app/rest/projects", _configuration.ChangeProviderConfiguration.Username, _configuration.ChangeProviderConfiguration.Password); var projects = new List <ChangeLogs.Project>(); var parents = toBuildChange.Projects.Where(p => !string.IsNullOrEmpty(p.ParentProjectId)).Select(p => p.ParentProjectId).Distinct(); foreach (var project in toBuildChange.Projects.Where(p => !parents.Contains(p.Id))) { var builds = new List <BuildResult>(); var allBuildTypes = this._webRequestHelper.GetXmlWebRequestWithBasicAuth <BuildTypes>( _configuration.ChangeProviderConfiguration.BaseUrl + $"/app/rest/buildTypes?locator=affectedProject:(id:{project.Id})&fields=buildType(id,name,builds($locator(count:{count},status:{status.ToString().ToUpper()},lookupLimit:{lookupLimit}),build(number,status,statusText)))", _configuration.ChangeProviderConfiguration.Username, _configuration.ChangeProviderConfiguration.Password); foreach (var allBuilds in allBuildTypes.Builds) { foreach (var buildConfig in allBuilds.Builds) { foreach (var build in buildConfig.Builds) { if (!includeFiltered && string.IsNullOrEmpty(build.Status)) { continue; } builds.Add(new BuildResult { BuildNumber = build.Number.ToString(), ConfigurationName = allBuilds.Name, Id = allBuilds.Id, Message = build.Statustext, WebUrl = build.WebUrl, Status = build.Status == "FAILURE" ? BuildStatus.Failure : (build.Status == "SUCCESS" ? BuildStatus.Success : (build.Status == "ERROR" ? BuildStatus.Error : BuildStatus.NotProvided)) }); } } } if (!includeFiltered && builds.Count == 0) { continue; } projects.Add(new ChangeLogs.Project { Builds = builds, Description = project.Description, Id = project.Id, Name = project.Name, WebUrl = project.WebUrl }); } return(projects); }
/// <summary> /// Update the status of a request /// </summary> /// <param name="projectName"></param> /// <param name="requestId"></param> /// <param name="newStatus"></param> /// <returns></returns> public async Task<string> UpdateBuildRequest(string projectName, int requestId, BuildStatus newStatus) { return await PatchResponse(string.Format("requests/{0}", requestId), new { status = newStatus.ToString() }, projectName, MediaType.JSON_MEDIA_TYPE); }
public BuildLocator WithBuildStatus(BuildStatus buildStatus) { return(With("status", buildStatus.ToString())); }