c#vsts批准了部署

时间:2019-10-30 14:03:03

标签: c# azure-pipelines

嗨,我成功地获得了批准,但是我不知道为什么在尝试使用此代码批准部署时会出现未经授权的错误 错误。我想要一个能够批准挂起部署的代码,如果没有,则必须重新部署并批准

  

Microsoft.VisualStudio.Services.Common.VssUnauthorizedException:'VS30063:您无权访问https://rmprodweu1.vsrm.visualstudio.com。'

var approval = rd.Deployment.PreDeployApprovals.FirstOrDefault();
        if (approval == null)
            return;

        var client = Connection.GetClient<ReleaseHttpClient2>();

        if (approval.Status != ApprovalStatus.Pending)
        {
            //rd.Environment.Status = EnvironmentStatus.InProgress;
            //rd.LastRelease = await client.UpdateReleaseAsync(rd.LastRelease, Config.Project, rd.LastRelease.Id);

            var deps = await client.GetDeploymentsAsync(
                    Config.Project,
                    definitionId: rd.LastRelease.ReleaseDefinitionReference.Id,
                    latestAttemptsOnly: true,
                    top: 1);
            rd.Deployment = deps.First();
            approval = rd.Deployment.PreDeployApprovals.FirstOrDefault();
        }

        approval.Status = ApprovalStatus.Approved;

        await client.UpdateReleaseApprovalAsync(
            approval,
            Config.Project,
            approval.Id
        );

0 个答案:

没有答案