tfs - TFS 2017 插件问题 - 捕获异常TF30063:您无权访问“https://tfs.com//TeamProject
问题描述
我正在尝试在 TFS 2017 中创建一个插件,该插件在签入前检查关联的工作项,如果不满足少数条件则拒绝签入。这适用于 One Collection 和 One TeamProject。现在我正在尝试在多个集合和团队项目中实现这一点,它会引发以下错误“TF30063:您无权访问” https://tfs.com//TeamProject “我正在粘贴下面的代码,请让我知道可能的问题是什么。
{
// Logic Goes here ...
bool isNullComment = false;
bool isDevBranchChange = false;
bool isCodeReviewRequest = false;
bool isCodeReviewResponse = false;
bool isTaskAssociated = false;
//Read all submitted items
var changes = notification.GetSubmittedItems(requestContext);
//Check if the changes have any DEV branch changes
isDevBranchChange = changes.Any(change => change.ToUpper().Contains("/DEV/"));
if (isDevBranchChange)
{
isNullComment = string.IsNullOrEmpty(notification.Comment.ToString());
var assoWorkItems = notification.NotificationInfo.WorkItemInfo.Select(x => x.Id); //Read all associated workitem id's
TfsTeamProjectCollection connection = new TfsTeamProjectCollection(GetTfsUri(requestContext));
WorkItemStore wiStore = connection.GetService<WorkItemStore>();
//check if any of associated workitem has code review
foreach (int id in assoWorkItems)
{
WorkItem wi = wiStore.GetWorkItem(id);
// Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItem wi = witClient.GetWorkItemAsync(id).Result;
if (wi.Type.Name.ToUpper().Equals("CODE REVIEW REQUEST"))
{
isCodeReviewRequest = true;
}
if (wi.Type.Name.ToUpper().Equals("TASK"))
{
isTaskAssociated = true;
}
if (wi.Type.Name.ToUpper().Equals("CODE REVIEW RESPONSE"))
{
isCodeReviewResponse = true;
}
}
if (!isCodeReviewRequest || isNullComment || !isCodeReviewResponse || !isTaskAssociated)
{
statusMessage = "Check-in Rejected. Check-in Comment, Task, Code Review Request and Code Review Response workitems are Required. \nFor more information, please contact TFS Administrators: vsalm@abc.com";
return EventNotificationStatus.ActionDenied;
}
}
}
catch (Exception exception)
{
statusMessage = "Caught an Exception" + exception.Message;
return EventNotificationStatus.ActionDenied;
// Any exception, TFS will disable it. So, Log it and eat it.
TeamFoundationApplicationCore.LogException("DecisionPoint plugin encountered the following error while processing events", exception);
}
}
return EventNotificationStatus.ActionPermitted;
}
private Uri GetTfsUri(IVssRequestContext _requestContext)
{
var locationService = _requestContext.GetService<ILocationService>();
return new Uri(locationService.GetServerAccessMapping(_requestContext).AccessPoint + "/" + _requestContext.ServiceHost.Name);
}
}
}
解决方案
推荐阅读
- javascript - 'stateMachineArn' 处的值为 null 未能满足约束:成员不得为 null
- python - 是否可以在 Keras 中释放 GPU 分配的资源?
- intellij-idea - 如何防止 IntelliJ IDEA 关闭多行注释?
- java - 根据填充的属性分组对象列表
- ruby - 如何获取值中的键名以在 Ruby 哈希中打印
- ios - 反馈助手网址是否损坏?
- javascript - 将嵌套数组中的 2 个值相乘然后推送到一个新数组 - JavaScript Vue
- python - 动态更新 Python 字典内容
- r - R如何用规则填写NA
- php - 将日期时间舍入到接下来的 15 分钟