public static VstsArtifactsHelper CreateArtifactsHelper(VstsMessage vstsContext) { var buildHttpClientWrapper = new BuildClient(vstsContext.VstsUri, new VssBasicCredential(string.Empty, vstsContext.AuthToken)); var gitClient = new GitClient(vstsContext.VstsUri, new VssBasicCredential(string.Empty, vstsContext.AuthToken)); var releaseClient = new ReleaseClient(vstsContext.VstsPlanUri, new VssBasicCredential(string.Empty, vstsContext.AuthToken)); var repositoryName = vstsContext.BuildProperties != null ? vstsContext.BuildProperties.RepositoryName : string.Empty; return(new VstsArtifactsHelper(buildHttpClientWrapper, releaseClient, gitClient, vstsContext.ProjectId, repositoryName)); }
internal static async Task <bool> IsSessionValid(VstsMessage vstsMessage, IBuildClient buildClient, IReleaseClient releaseClient, CancellationToken cancellationToken) { var projectId = vstsMessage.ProjectId; if (vstsMessage.VstsHub == HubType.Build) { var buildId = vstsMessage.BuildProperties.BuildId; return(await BuildClient.IsBuildValid(buildClient, projectId, buildId, cancellationToken).ConfigureAwait(false)); } if (vstsMessage.VstsHub == HubType.Release) { var releaseId = vstsMessage.ReleaseProperties.ReleaseId; return(await ReleaseClient.IsReleaseValid(releaseClient, projectId, releaseId, cancellationToken).ConfigureAwait(false)); } throw new NotSupportedException(string.Format("VstsHub {0} is not supported", vstsMessage.VstsHub)); }