我目前正在开发Team Foundation Server 2017的扩展程序。
扩展最终应该能够做的是将工作项移动到特定状态,然后在某处调用Web服务。
但是我遇到了一个问题,每当工作项在不同的泳道之间移动时,似乎无法订阅。
我当前的清单文件(vss-extension.json)如下所示:
{
"manifestVersion": 1,
"id": "xxxx-mes-assyst-plugin",
"version": "0.1.6",
"name": "xxxx MES Assyst plugin",
"description": "Connects to MES Teams assyst",
"publisher": "xxxx-System-A-S",
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
}
],
"icons": {
"default": "images/logo.png"
},
"contributions": [
{
"id": "sample-work-item-form-notifications",
"type": "ms.vss-work-web.work-item-notifications",
"description": "Gets events about the current work item form",
"targets": [
"ms.vss-work-web.work-item-form"
],
"properties": {
"uri": "workItemNotifications.html"
}
}],
"scopes": [
"vso.work",
"vso.work_write"
],
"files": [
{
"path": "workItemNotifications.html", "addressable": true
},
{
"path": "scripts", "addressable": true
},
{
"path": "images", "addressable": true
},
{
"path": "sdk/scripts", "addressable": true
}
]
}
我的workItemNotifications.html如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Work item extension page sample</title>
</head>
<body>
<script src="sdk/scripts/VSS.SDK.js"></script>
<script>
VSS.init({
explicitNotifyLoaded: true,
usePlatformScripts: true
});
VSS.ready(function () {
// Register a listener for the work item page contribution.
VSS.register(VSS.getContribution().id, function (context) {
return {
// Called when the active work item is modified
onFieldChanged: function(args) {
console.log("onFieldChanged");
console.log("----------- ARGS -----------");
console.log(args);
},
// Called when a new work item is being loaded in the UI
onLoaded: function (args) {
console.log("onLoaded");
console.log("----------- ARGS -----------");
console.log(args);
},
// Called when the active work item is being unloaded in the UI
onUnloaded: function (args) {
console.log("onUnloaded");
console.log("----------- ARGS -----------");
console.log(args);
},
// Called after the work item has been saved
onSaved: function (args) {
console.log("onSaved");
console.log("----------- ARGS -----------");
console.log(args);
},
// Called when the work item is reset to its unmodified state (undo)
onReset: function (args) {
console.log("onReset");
console.log("----------- ARGS -----------");
console.log(args);
},
// Called when the work item has been refreshed from the server
onRefreshed: function (args) {
console.log("onRefreshed");
console.log("----------- ARGS -----------");
console.log(args);
}
}
});
VSS.notifyLoadSucceeded();
});
</script>
</body>
</html>
只要工作项表单发生更改,此代码就可以工作,但是我想订阅工作项移动/更改通道之间状态的事件。
我尝试添加像“ms.vss-work-web.backlog-item-notifications”这样的目标 - 刚刚返回并出错,因为它不是有效目标。
有人知道该怎么做吗?
答案 0 :(得分:1)
我担心无法通过VSTS扩展来实现,因为据我所知,对于板面板中的工作项目没有贡献目标。正如Nicolai在评论中提到的那样,解决方法是创建一个Web服务来订阅VSTS Service Hook以跟踪工作项的变化。