public async Task Handle(HealthCheckRequest <VSTSRelease_v1> request, CancellationToken cancellationToken) { var widget = request.DataContext ?? throw new InvalidOperationException(); var client = new VstsClient(); widget.MapTo(client); if (widget.ReleaseId == null) { var definition = await client .GetReleaseDefinitionAsync(widget.ReleaseDefinitionName) .ConfigureAwait(false); widget.ReleaseId = definition.Id; } var lastRelease = await client .GetLastReleaseAsync(widget.ReleaseId.Value) .ConfigureAwait(false); var releaseDetails = await client .GetReleaseDetailsAsync(lastRelease.Id) .ConfigureAwait(false); RemoveEnvironments(widget, releaseDetails.Environments); AddEnvironments(widget, releaseDetails); }
public void Handle(VSTSRelease_v1 vstsRelease) { var client = new VstsClient { Connection = new VstsConnection { Account = vstsRelease.Account, Project = vstsRelease.Project, UserName = vstsRelease.UserName, Password = vstsRelease.Password, } }; if (vstsRelease.DefinitionId == null) { var definition = client.GetReleaseDefinitionAsync(vstsRelease.ReleaseDefinitionName).Result; vstsRelease.DefinitionId = definition.Id; } var latestRelease = client.GetLatestReleaseAsync(vstsRelease.DefinitionId.Value).Result; var releaseDetails = client.GetReleaseDetailsAsync(latestRelease.Id).Result; RemoveEnvironments(vstsRelease, releaseDetails); AddEnvironments(vstsRelease, releaseDetails); }
public void Handle(VSTSBuild_v1 vstsBuild) { var vstsClient = new VstsClient(new VstsConnection()); vstsBuild.MapTo(vstsClient.Connection); if (vstsBuild.DefinitionId == null) { var definition = vstsClient.GetBuildDefinitionAsync(vstsBuild.DefinitionName).Result; vstsBuild.DefinitionId = definition.Id; } var latestBuild = vstsClient.GetLatestBuildAsync(vstsBuild.DefinitionId.Value).Result; vstsBuild.State = latestBuild != null ? latestBuild.State : State.Unknown; }
public async Task Handle(HealthCheckRequest <VSTSBuild_v1> request, CancellationToken cancellationToken) { var client = new VstsClient(); request.DataContext.MapTo(client.Connection); if (request.DataContext.DefinitionId == null) { var definition = await client.GetBuildDefinitionAsync(request.DataContext.DefinitionName).ConfigureAwait(false); request.DataContext.DefinitionId = definition.Id; } var build = await client.GetLatestBuildAsync(request.DataContext.DefinitionId.Value) .ConfigureAwait(false); request.DataContext.State = build != null ? build.State : State.Unknown; }
public async Task Handle(HealthCheckRequest <VSTSBuild_v1> request, CancellationToken cancellationToken) { var client = new VstsClient(); request.DataContext.MapTo(client); if (request.DataContext.DefinitionId == null) { var definition = await client.GetBuildDefinitionAsync(request.DataContext.DefinitionName).ConfigureAwait(false); request.DataContext.DefinitionId = definition.Id; } var builds = await client.Request <Collection <VSTSBuild> >($"build/builds?definitions={request.DataContext.DefinitionId}&$top=1&api-version=2.0").ConfigureAwait(false); var build = builds?.Value?.FirstOrDefault(); request.DataContext.State = build != null ? build.State : State.Unknown; }
public async Task Handle(HealthCheckRequest <VSTSRelease_v1> request, CancellationToken cancellationToken) { var client = new VstsClient(new VstsConnection()); request.DataContext.MapTo(client.Connection); if (request.DataContext.DefinitionId == null) { var definition = await client.GetReleaseDefinitionAsync(request.DataContext.ReleaseDefinitionName) .ConfigureAwait(false); request.DataContext.DefinitionId = definition.Id; } var latestRelease = await client.GetLatestReleaseAsync(request.DataContext.DefinitionId.Value) .ConfigureAwait(false); var releaseDetails = await client.GetReleaseDetailsAsync(latestRelease.Id) .ConfigureAwait(false); RemoveEnvironments(request.DataContext, releaseDetails); AddEnvironments(request.DataContext, releaseDetails); }