有一个用于开发AzureDevOps UI扩展的新库,但是发行版存在问题
当我使用api版本时,当我是项目和网站azureDevOps的管理员时,出现401错误
import * as SDK from "azure-devops-extension-sdk";
import { CommonServiceIds, IProjectPageService, getClient } from "azure-
devops-extension-api";
import * as vsrelease from "azure-devops-extension-api/Release";
import * as vsbuild from "azure-devops-extension-api/Build";
await SDK.ready();
// get current project name
const projectService = await SDK.getService<IProjectPageService>(CommonServiceIds.ProjectPageService);
const project = await projectService.getProject();
let projectName = '';
if(project !== undefined) projectName = project.name;
console.log(projectName);
// get buildDefinitions = ok
const buildDefinitions = await getClient(vsbuild.BuildRestClient).getDefinitions(
projectName, undefined, undefined, undefined,
undefined, undefined, undefined, undefined, undefined,
undefined, undefined, undefined, true, true );
console.log(buildDefinitions);
// get releaseDefinitions == error 401 ??
// {"$id":"1","innerException":null,"message":"TF400813: The user 'my admin guid' is not authorized to access this resource.","typeName":"Microsoft.TeamFoundation.Framework.Server.InvalidIdentityException, Microsoft.TeamFoundation.Framework.Server","typeKey":"InvalidIdentityException","errorCode":0,"eventId":3000}
const releaseDefinitions = await getClient(vsrelease.ReleaseRestClient).getReleaseDefinitions(projectName);
console.log(releaseDefinitions);
https://github.com/Microsoft/azure-devops-extension-api/issues/2 https://github.com/Microsoft/azure-devops-extension-sdk/issues/3
我在github上没有答案
感谢您的帮助。
答案 0 :(得分:0)
您必须为扩展的清单文件添加权限
"scopes": [
"vso.release",
"vso.build"
],
,您将必须在常规扩展部分中授权对AzureDevOps的新权利