VSTS: Pass build/release variables into Powershell script task

前端 未结 4 1853
忘掉有多难
忘掉有多难 2020-12-04 16:32

Ideally, I would want to configure our Azure Web App application settings using build variables (on VSTS), for example:

We perform our publish tasks using P

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 17:27

    Build Variables are automatically passed to all the PowerShell scripts as environment variables.

    So if you have defined a variable myVar in the Variables section. You can access it as $env:myVar in your script. One thing to note here is that . is converted to a _. For eg. if your variable is myVar.config, you will access it in your script as $env:myVar_config.

    The available variables also include variables such as branch name, build number etc. To see all the available variables, run a dummy build/release definition and add a PowerShell task with inline type and run Get-ChildItem Env:. This will show you all the available environment variables and you can see all your custom defined variables.

    More details are available here

提交回复
热议问题