VSTS NodeJS API队列构建

时间:2018-11-06 17:23:20

标签: node.js azure-devops azure-pipelines-build-task azure-devops-rest-api

我想通过NodeJS VSTS API (azure-devops-node-api)

对构建进行排队

因此,我使用getDefinition来获取构建定义,然后使用queueBuild并返回结果:

connection.getBuildApi().then((vstsBuild) => {
    vstsBuild.getDefinition(buildPublishToNexus, project).then((buildDefinition) => {
        vstsBuild.queueBuild(buildDefinition, project).then((defs) => {
            console.info('build', defs);
        }).catch(err => console.error('catch 1', err));
    }).catch(err => console.error('catch 2', err));
});

我获得了包含所有参考的构建,但是它不断告诉我这个错误:

{ '$id': '1',
     innerException: null,
     message: 'Value cannot be null.\r\nParameter name: build.Definition',
     typeName: 'System.ArgumentNullException, mscorlib',
     typeKey: 'ArgumentNullException',
     errorCode: 0,
     eventId: 0 } }

有人了解如何获取build.Definition吗?文档确实很差。

1 个答案:

答案 0 :(得分:0)

因此,我在vsts github的问题中找到了解决方案:

  

我建议在UI中对构建进行排队,并使用chrome,fiddler和charles观看连线。比较。我们的Web UI使用所有公共的api,因此已实现:)。比文档更准确...

所以有效载荷看起来像:

        const vstsdef = {
        'queue': {'id': 1},
        'definition': {'id': 1},
        'project': {'id': '5fe64329-b654-4a20-a73c-375636ef1879'},
        'sourceBranch': 'refs/heads/mybranch',
        'sourceVersion': '',
        'reason': 1,
        'demands': ['option demands'],
        'parameters': '{"key":"value"}'
    };
相关问题