0
votes

I'm using version 4.1-preview.6 for a call to VSTS' Release API and it looks like whenever it creates a new release, the release's title will not be the expected title, "Release-#" but instead is a negative number like "-1." I'm using PowerShell. I can see in the Web UI that the Release name format is $(Build.BuildNumber)-$(rev:r).

  1. Is there a different version of the REST API that fixes this?
  2. Or is there a parameter I'm missing in the body?

Request body (excludes variables set earlier in the script and function for Invoke-RestMethod):

    $uri = "https://$($accountName).vsrm.visualstudio.com/$($projectName)/_apis/release/releases?api-version=4.1-preview.6"

    $body = @{
        "definitionId" = "$($releaseDefinitionId)"
        "description" = "Creating automated release"
    }
    $body.Add("artifacts", @())
    $artifact = @{
        "alias" = "$($buildDefinitionName)"
        "instanceReference" = @{
            "id" = "$($buildId)"
            "name" = $null
        }
    }
    $body.artifacts += $artifact

    $jsonBody = $body | ConvertTo-Json -Depth 5

    $response = Invoke-RestCommand -uri $uri -commandType "POST" -jsonBody $jsonBody -personalAccessToken $personalAccessToken

Response:

id                         : 4
name                       : -4
status                     : active
createdOn                  : 2018-06-12T04:27:18.237Z
modifiedOn                 : 2018-06-12T04:27:18.237Z
1

1 Answers

0
votes

You need to check how you define release name format in your definition:

enter image description here