romuleald
romuleald

Reputation: 1434

VSTS NodeJS API queue build

I want to queue a build via the NodeJS VSTS API (azure-devops-node-api)

So i use the getDefinition to get my build definition, then queueBuild with the returned result:

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));
});

I get my build with all its reference but it keeps telling my this error:

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

Does someone have any information on how to get the build.Definition? The documentation is really poor.

Upvotes: 1

Views: 365

Answers (1)

romuleald
romuleald

Reputation: 1434

So I found the solution in the issues of the vsts github :

I would recommend queuing a build in the UI and watching the wire with chrome, fiddler, charles. Compare. Our web UI uses all public rest apis so it's implemented :) . More accurate than docs ...

So the payload would looks like:

        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"}'
    };

Upvotes: 1

Related Questions