typescript - azure-devops-扩展-api (sdk) : APIs error when using in pipeline extension

标签 typescript azure-devops azure-devops-rest-api azure-devops-extensions

我正在构建 Azure DevOps 管道扩展并希望使用数据 Storage feature

我正在使用 typescript 进行开发和以下 API:
- azure-devops-extension-api
- azure-devops-extension-sdk

我能够编写一个函数并且它可以毫无问题地编译:

const extensionId = SDK.getExtensionContext().extensionId;
const accessToken = await SDK.getAccessToken();
const dataService = await SDK.getService<IExtensionDataService>(CommonServiceIds.ExtensionDataService);
const manager = await dataService.getExtensionDataManager(extensionId, accessToken);
const document = await manager.getDocument('MyCollection', 'MyDocument');
document.action = 'hello world - pipeline';
manager.updateDocument('MyCollection', document).then(function (doc) {
  LoggingUtils.logMessage(`Doc version: ${doc.__etag}`);
});

问题是在运行时出现错误:Unhandled: define is not defined

这个问题与模块有关,但我不知道这里有什么问题。我试图将 tsconfig 中的 module 参数更改为 commonjsamdumd这没有帮助。

最佳答案

最后,我找到了如何在管道扩展应用程序中使用数据存储的解决方案。

我已经创建了一个存储库及其用法示例:
https://github.com/parkhomenko/azure-build-task/blob/master/nodeFiles/index.ts

关于typescript - azure-devops-扩展-api (sdk) : APIs error when using in pipeline extension,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57255304/

相关文章:

azure-devops - 仅当拉取请求已成功合并到 master 时,如何调用 webhook?

python - 使用 Azure API 在 Azure Boards 上创建新任务

angular - Angular 中的日期和货币验证 (4)

inheritance - 在 typescript 中使用具有不同 namespace 的接口(interface)

javascript - 实例化 Injectable 类时未调用 ngOnInit

angular - 带 ngx-translate 的 Ionic 3 - 延迟加载在浏览器中有效,但在构建后在 android 中无效

azure - Azure DevOps 服务是否支持租户限制?

aws-lambda - DevOps : AWS Lambda . zip 与 Terraform

angular - 在 VSTS 中包含代码覆盖率报告,VSTS 是否必须使用测试适配器?