Press "Enter" to skip to content

Trigger build script for TFS

When building software, you want to focus on… building software. One of the things we used to do when CI servers were not invented yet, was manually regression testing code changes in shared components. It was a error prone process and CI servers made this process a lot easier. When we were using Jenkins as our CI server, there was an option (plugin) to trigger builds when one was succesfully finished. With a dependency matrix in the one hand, and this plugin in the other… regression testing was done automatically.

A few weeks ago we’ve moved to TFS 2015 (update 1) and the last couple of day’s I’ve worked on moving our builds to TFS. I was surprised to see that there was no alternative to our Jenkins build trigger option. I thought that this was something very standard and implemented in all CI servers, but I was wrong. The official answer to the question “Can I chain builds so that one build triggers another?” is “Not yet“.

Luckily for us, the TFS build system is very easy to extend with custom powershell scripts. Combine this extensibility with the REST api and you can build a “trigger build” step quit easily. I’ve created a gist which shows how to trigger new builds as a TFS step.

  • Lars Lykke

    Thank you for this post. I too have struggled with the missing trigger mechanism when moving from Jenkins to TFS. What I had missed was the use of the -useDefaultCredentials parameter on the invoke-restmethod call. That would allow me to actually get a build triggered in the name of the user who triggered the original build.
    Thank you for this!

  • Tom Kuijsten

    With extensions made possible in update 2, we could create a Build task 🙂