1

So I have 1 default publish build definition and I would like to have another one which is in sync with it and does all the same steps but with an additional step at the end.

Can I have another build definition as one of the steps within another build definition?

This question is for Visual Studio Team Services latest.

ditoslav
  • 4,563
  • 10
  • 47
  • 79

2 Answers2

5

There are two ways to run another build in your current build.

Option 1: add PowerShell task in your current build definition to queue another build by REST API

Assume another build id is 5, so you can add PowerShell task with the script:

$body = @{
definition = @{
id = 5    
}
}
$Uri = "http://account.visualstudio.com/DefaultCollection/project/_apis/build/builds?api-version=2.0"
$buildresponse = Invoke-RestMethod -Method Post -UseDefaultCredentials -ContentType application/json -Uri $Uri -Body (ConvertTo-Json $body)  

Option 2: install related extension in Market place

There are some extensions you can install for your VSTS account, then you can add the task to queue another build. such as Queue Build(s) Task, Trigger New Build, Queue New Build etc.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • How do you get the Invoke-RestMethod to use the OAuth token? This isn't working for me. – TravisEz13 May 23 '18 at 20:44
  • 1
    @TravisEz13 You can also refer this post https://stackoverflow.com/questions/50483072/how-to-queue-a-new-build-using-vsts-rest-api. – Marina Liu May 24 '18 at 01:23
0

It appears this is now enabled without an extension through the UI: https://github.com/MicrosoftDocs/vsts-docs/issues/561

irhetoric
  • 362
  • 2
  • 9