1

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.

1 Answer 1

1

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"}'
    };
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.