Esempio n. 1
0
        public ReleaseApproval UpdateApproval(int approvalId, string accessToken)
        {
            if (approvalId < 0)
            {
                throw new ArgumentException("id cannot be less than 0", nameof(approvalId));
            }
            if (string.IsNullOrWhiteSpace(accessToken))
            {
                throw new ArgumentException("parameter cannot be null or whitespace", nameof(accessToken));
            }

            this.logger.LogDebug($"updating approval. approval id:[{approvalId}]");

            ReleaseApproval approval = new ReleaseApproval
            {
                Status   = ApprovalStatus.Approved,
                Comments = ApproveMessage
            };

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

            return(client.UpdateReleaseApprovalAsync(
                       approval,
                       this.vstsConfig.ProjectName,
                       approvalId).Result);
        }
Esempio 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);
            }
        }