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)

Leave a Reply

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