1

一个用于开发 AzureDevOps UI 扩展的新库可用,但我对发布部分有疑问

当我使用 api 版本时,我收到 401 错误,而我是我的项目和网站 azureDevOps 的管理员

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上没有答案

谢谢你的帮助。

4

1 回答 1

1

您必须为扩展的清单文件添加权限

    "scopes": [
    "vso.release",
    "vso.build"
    ],

并且您必须在常规扩展部分中授权 AzureDevOps 的新权限

于 2018-11-27T13:18:25.747 回答