Octopus initiate a TFS build


My search-fu is not strong enough to find if this has been asked before, so pointers to previous discussions would be very helpful.

We have a situation where instead of TFS initiating deployment, we want deployment to initiate builds. Our user story is that as a release management team member, I want to be able to build a sandbox development environment out of Octopus so that the developers have the latest code in their project sandbox. That means when I deploy the sandbox, I would like Octopus to tell TFS to build the various services, websites and databases, Octopus to use the latest package available in the Nuget feed, and then deploy them.

I’ve found plenty of the CI process documented, but not so much on how I can achieve what I want. Any tips/pointers/solutions?

Thank you!

Hi Michael,

Thanks for reaching out! Its quite possible that your search-fu is working just fine, as this is not a usual request. Like you mentioned, usually people do it the other way around. But i totally understand how it fits on your process :slight_smile:

You could achieve this by triggering a build from a Powershell step. There seems to be 2 ways to do it:

REST API - You can use powershell and the cmdlet Invoke-RestMethod to call the TFS rest API and trigger a build from there. I believe this has been available since TFS2012, but not sure. Definitely available on TFS2013 and VSO. https://www.visualstudio.com/en-us/integrate/api/build/requests#Requestabuild

Command Line - See TFBuild.exe https://msdn.microsoft.com/en-us/library/ms181742(v=vs.100).aspx

If your script-fu is strong enough, you can even create a Step Template and have it available for all your Projects.

Hope that helps!


Thanks Dalmiro,

As a follow-up question - when I create a release, I pick the “Latest” package for Octopus to deploy. If, as part of the release process, I create a newer version, will he pick up that later version?

For example:

I am creating a release and the latest for WebsiteX is So as part of this release, I fire off a TFS build and he creates Will Octo pick up that .2 version or stick with the .1 version that was the “latest” when the release was created?

Thank you! The support is one of the reasons we are working very hard to get TPTB to authorize the Enterprise purchase, we want this tool!

Hi Michael,

When you create a release, Octopus will pick the latest existing package at that moment. Its not possible to select a package that was created after the release. You might be able to achieve this by having 2 projects

  1. The project that triggers the build.
  2. The project that deploys the new package ( You could the deployent of this project right from the build you triggered on (1) using Octopack, so the whole process depends on you just starting a deployment on (1).