通过VSTS Rest API创建发布:如何设置变量值及命名规范?
Setting Release Variables via VSTS/Azure DevOps REST API's ReleaseStartMetadata
Great question! Let's break this down clearly for you:
Core Answer
Yes, you can set release-level variable values using the properties collection in the ReleaseStartMetadata object when creating a release via the REST API. But you do need to follow a specific naming convention for the property keys to make it work.
Required Naming Format & Examples
- Each variable entry in
propertiesmust use the key pattern:releaseVariables.{YourVariableName} - The value for each key needs to be an object containing a
valuefield (this is the actual value you want to assign to the variable). Here's a practical JSON example:"properties": { "releaseVariables.DeployTargetEnv": { "value": "Production" }, "releaseVariables.BuildVersionTag": { "value": "v2.4.1" } } - For secret variables (values that require encrypted storage), add an
isSecret: trueproperty to the object:"properties": { "releaseVariables.DBAdminPassword": { "value": "SecurePass_123!", "isSecret": true } }
Key Notes
- These values will override the default variable settings in your release definition, but only for the specific release instance you're creating.
- Ensure the variable name (the part after
releaseVariables.) matches exactly with the variable name in your release definition—this is case-sensitive, so double-check spelling and capitalization to avoid issues!
内容的提问来源于stack exchange,提问作者cdarrigo
相关产品推荐
相关产品推荐

