Exemplo n.º 1
0
        public IEnumerable <ReleaseApproval> GetApprovals(int releaseId, string accessToken)
        {
            if (releaseId < 0)
            {
                throw new ArgumentException("id cannot be less than 0", nameof(releaseId));
            }
            if (string.IsNullOrWhiteSpace(accessToken))
            {
                throw new ArgumentException("parameter cannot be null or whitespace", nameof(accessToken));
            }

            this.logger.LogDebug($"getting approvals. release id:[{releaseId}]");

            ReleaseHttpClient client = this.GetClient <ReleaseHttpClient>(accessToken);

            return(client.GetApprovalsAsync(
                       this.vstsConfig.ProjectName,
                       releaseIdsFilter: new int[] { releaseId }).Result);
        }
Exemplo n.º 2
0
        public void ApprovePendingRelease()
        {
            string projectName      = ClientSampleHelpers.FindAnyProject(this.Context).Name;
            string assignedToFilter = ClientSampleHelpers.GetCurrentUserDisplayName(this.Context);

            // Get a release client instance
            VssConnection     connection     = Context.Connection;
            ReleaseHttpClient releaseClient  = connection.GetClient <ReleaseHttpClient>();
            ReleaseApproval   updateApproval = new ReleaseApproval {
                Status = ApprovalStatus.Approved, Comments = "Good to go!"
            };

            // Get all pending approval to the current user
            IList <ReleaseApproval> releaseApprovalsPage     = releaseClient.GetApprovalsAsync(project: projectName, assignedToFilter: assignedToFilter).Result;
            ReleaseApproval         releaseApprovalToApprove = releaseApprovalsPage.FirstOrDefault();

            if (releaseApprovalToApprove != null)
            {
                ReleaseApproval approval = releaseClient.UpdateReleaseApprovalAsync(project: projectName, approval: updateApproval, approvalId: releaseApprovalToApprove.Id).Result;

                Console.WriteLine("{0} {1}", approval.Id.ToString().PadLeft(6), approval.Status);
            }
        }