问题描述
我有多个 Azure PowerShell 任务,我想在其中传递变量.目前我正在使用脚本参数传递变量,如截图所示:
I have multiple Azure PowerShell tasks in which I'd like to pass variables. Currently I'm passing variables with Script Arguments, like on the screenshot:
脚本参数的问题在于,如果有更改,我必须在每个进程中对其进行编辑.是否有可能只有一个变量可以链接到多个进程?我看过 VSTS:将构建变量传递到 Powershell 脚本任务 但无论我如何编辑我的脚本,他们都拒绝工作.该主题也没有解释是否应该将变量放入流程变量或队列构建变量中.这是我试图自动化的脚本:
The problem with Script Arguments is that I'd have to edit them in every process if there is a change. Is it possible to have just a single variable that I can link to multiple processes? I've looked at VSTS: Pass build variables into Powershell script task but no matter how I edit my scripts they refuse to work. That topic also doesn't explain if variables should be put into process variables or Queue Build Variables. Here is the script that I'm trying to automate:
param
(
[Parameter(Mandatory)]
[String]$NewFileLocation1
)
Set-AzureRmVMCustomScriptExtension -Argument "-NewFileLocation1 $NewFileLocation" -ResourceGroupName Test-RG1`
-VMName VM1 `
-Location northeurope `
-FileUri https://raw.githubusercontent/x/assets/master/PowerShell/PS1/PS1/PS1.ps1 `
-Run 'PS1.ps1' `
-Name PS1
PS1.ps:
param
(
[Parameter(Mandatory)]
[String]$NewFileLocation
)
New-Item $NewFileLocation
推荐答案
这是我正在使用的:
Param (
[string]$location = $env:location,
...
[string]$tagEnvironment = $env:tagEnvironment
)
我正在使用 VSTS 库变量组,您可以将变量组链接到不同的发布管道.
I'm using VSTS Library Variable groups, you can link variable groups to different release pipelines.
这篇关于VSTS 将变量传递到 Azure PowerShell 脚本参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论