TFS Release Management: Create Release via REST API

I recently had to come up with a solution to perform a bulk deploy of all apps to an environment using the latest build artifacts. I wanted to use a “wrapper” release definition to orchestrate all of the deployments; similar to how Octopus Deploy’s “Deploy Release Step” works.

However, TFS Release Management currently lacks functionality to create releases from within a build or release definition. There are 3rd party extensions to queue/trigger other builds within a build definition, but nothing to create releases.

I created a PowerShell script, CreateRelease.ps1, that creates a new release for the specified release definition name, using the latest artifact versions available. I created a new “wrapper” release definition, that has multiple “Run a PowerShell script” steps that run CreateRelease.ps1, for each release definition I want to create releases for.

At a high level level, the steps that the script performs are as follows:

  1. Finds release definition using $ReleaseDefinitionName that’s passed as an argument
  2. Gets list of all linked artifacts
  3. Gets list of artifact versions
  4. Creates a new release using latest version of linked artifacts
  5. Wait for deployment to complete (triggered upon release creation)

2 thoughts on “TFS Release Management: Create Release via REST API

  1. Hi sir,

    This is really nice content in VSTS but i have some doubts in this which is listed below.
    1. Where can we define ReleaseDefination Name?
    2. I have created one release definition with the specific version. can you please explain how can i trigger that release with powershell from another release definition?

Leave a Reply

Your email address will not be published. Required fields are marked *