VSTS Rest API - Create Release

无人久伴 提交于 2019-12-04 01:43:03

问题


I'd like to start a release leveraging the VSTS Rest API defined here: https://www.visualstudio.com/en-us/docs/integrate/api/rm/releases#create-a-release

but I need to set some of the variable values when I create the release. Looking at the ReleaseMetadata (https://www.visualstudio.com/en-us/docs/integrate/api/rm/contracts#ReleaseStartMetadata) I see there is a properties collection. Is this where I'd set the variable values? Is there any special naming convention I need to use in the property name to translate it the variable name? (like ##VSTS:[])??


回答1:


Now you can define VSTS Release variables to be "Settable at release time" as shown below.

Then you can use below json syntax in VSTS REST API call request body to pass the variable values to set at the time of creating the release.

"variables": {
    "Variable1Name": {
      "value": "Variable1Value"
    },
    "Variable2Name": {
      "value": "Variable2Value"
    }
  }

For more information refer the post here.




回答2:


Unfortunately, for now it's not able to set variable values when you created a release. This is unlike Build definition for VSTS, variables are allowed to change their values at queue time.

There has been a related uservoice, you could vote for it:

Change release variables' value when deploy a release

https://visualstudio.uservoice.com/forums/330519-visual-studio-team-services/suggestions/16616269-change-release-variables-value-when-deploy-a-rele

As a workaround, you could create a draft release, then update variables’ value ,after that, you can start the release by Modifying the status of a release (active)

{
    "status": "Active"
}

More detail info please take a look this similar question: Release Variables through REST API - Visual Studio Team Services



来源:https://stackoverflow.com/questions/49283685/vsts-rest-api-create-release

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!