Posts

Showing posts with the label REST API

Create a draft release and start it using the TFS REST API

The code below uses the preview API to retrieve a release definition, create a new draft release from the latest build, update some variables, then activate the release and start the deployment on a specific environment. It serves as a reference regarding how to use the RM API. I used the following nuget packages: <packages>   <package id="Microsoft.AspNet.WebApi.Client" targetframework="net452" version="5.2.3"/>   <package id="Microsoft.AspNet.WebApi.Core" targetframework="net452" version="5.2.3"/>   <package id="Microsoft.IdentityModel.Clients.ActiveDirectory" targetframework="net452" version="3.14.1"/>   <package id="Microsoft.TeamFoundation.DistributedTask.Common.Contracts" targetframework="net452" version="15.118.0-preview"/>   <package id="Microsoft.TeamFoundationServer.Client" targetframework="net452...

Retrieving the current iteration from a TFS Build vNext

One of my clients wanted to include the current iteration name in the build number format. I created a PowerShell script to retrieve it into a build variable named Build.PackageVersion $Uri = "$(System.TeamFoundationCollectionUri)/$(System.TeamProject)/$(System.Team)/_apis/work/TeamSettings/Iterations?`$timeframe=current&api-version=3.0" $Response = Invoke-RestMethod -Method Get -UseDefaultCredentials -ContentType application/json -Uri $Uri $IterationName = $Response.value.name Write-Host "##vso[task.setvariable variable=Build.PackageVersion;]$IterationName" The System.Team variable is a custom one to avoid hard coding inside the script.  The script is executed via a build task from the marketplace:  https://marketplace.visualstudio.com/items?itemName=ms-devlabs.utilitytasks Then I used the tasks from Jesse Houwing to update the build number at build time: https://marketplace.visualstudio.com/items?itemName=jessehouwing.jessehouwing-vsts-variable-tas...