microsoft / azure-devops-dotnet-samples

.NET/C# samples for integrating with Azure DevOps Services and Azure DevOps Server
https://docs.microsoft.com/azure/devops/integrate
MIT License
522 stars 518 forks source link

Snippet for queueing a build definition #249

Closed tomaustin700 closed 5 years ago

tomaustin700 commented 5 years ago

Hi,

Are you able to give me an example showing how to queue a build definition?

Thanks.

tomaustin700 commented 5 years ago

Figured it out myself, here is an example:

var buildInstance = new Build
{
    Definition = new DefinitionReference
       {
         Id = definition.Id
       },
      Project = definition.Project,
};

await buildConnection.QueueBuildAsync(buildInstance);

Call GetDefinitionsAsync or GetDefinitionAsync off the BuildHttpClient to get the definition.