如何重置 Azure DevOps 输入变量的值?
How do you reset the value of an Azure DevOps input variable?
如何重置 Azure DevOps Get-VstsInput
变量的值?
我运行从本地的自定义任务中使用 PowerShell 脚本来检查它是否按预期工作...
Invoke-VstsTaskScript -ScriptBlock { . ..\buildAndReleaseTask\main.ps1 }
我第一次 运行 脚本时,我得到了各种值的提示。脚本使用 SDK 函数 Get-VstsInput.
获取输入
但在随后的 运行 脚本中,值已经设置。
但是我在文档中看不到任何关于如何重置该值的指示。
代码从获取用户在 Azure DevOps 管道对话框中填写的所需值开始...
$serverName= Get-VstsInput -Name "serverName" -Require
我已经检查了环境变量,但那里什么也没有。
我找到的唯一解决方案是关闭我的 PowerShell 控制台。
来自文档:
For the convenience of interactive testing, the module will prompt for undefined task variables and inputs. For example, Get-VstsTaskInput -Name SomeVariable will prompt for the value if the task variable is not defined. If a value is entered, then it will be stored so that subsequent calls will return the same value. Task variables are stored as environment variables. Inputs and endpoints are stored internally within the VstsTaskSdk module and can be cleared by removing and re-importing the module.
所以调用 Remove-Module VstsTaskSdk
应该可以解决问题。
我倾向于通过环境变量设置我的变量和输入,而不是依赖交互模式,这使得它们更容易更改并且在 Node 和 Powershell 处理程序之间工作相同:
# Task variable 'Build.SourcesDirectory':
$env:BUILD_SOURCESDIRECTORY = [...]
# Input 'MyInput':
$env:INPUT_MYINPUT = [...]
# Endpoint:
$env:INPUT_MYENDPOINT = 'EP1'
$env:ENDPOINT_URL_EP1 = 'https://[...]'
$env:ENDPOINT_AUTH_EP1 = '{ "Parameters": { "UserName": "Some user", "Password": "Some password" }, "Scheme": "Some scheme" }'
$env:ENDPOINT_DATA_EP1 = '{ "Key1": "Value1", "Key2": "Value2" }'
另请参阅:
如何重置 Azure DevOps Get-VstsInput
变量的值?
我运行从本地的自定义任务中使用 PowerShell 脚本来检查它是否按预期工作...
Invoke-VstsTaskScript -ScriptBlock { . ..\buildAndReleaseTask\main.ps1 }
我第一次 运行 脚本时,我得到了各种值的提示。脚本使用 SDK 函数 Get-VstsInput.
获取输入但在随后的 运行 脚本中,值已经设置。 但是我在文档中看不到任何关于如何重置该值的指示。
代码从获取用户在 Azure DevOps 管道对话框中填写的所需值开始...
$serverName= Get-VstsInput -Name "serverName" -Require
我已经检查了环境变量,但那里什么也没有。
我找到的唯一解决方案是关闭我的 PowerShell 控制台。
来自文档:
For the convenience of interactive testing, the module will prompt for undefined task variables and inputs. For example, Get-VstsTaskInput -Name SomeVariable will prompt for the value if the task variable is not defined. If a value is entered, then it will be stored so that subsequent calls will return the same value. Task variables are stored as environment variables. Inputs and endpoints are stored internally within the VstsTaskSdk module and can be cleared by removing and re-importing the module.
所以调用 Remove-Module VstsTaskSdk
应该可以解决问题。
我倾向于通过环境变量设置我的变量和输入,而不是依赖交互模式,这使得它们更容易更改并且在 Node 和 Powershell 处理程序之间工作相同:
# Task variable 'Build.SourcesDirectory':
$env:BUILD_SOURCESDIRECTORY = [...]
# Input 'MyInput':
$env:INPUT_MYINPUT = [...]
# Endpoint:
$env:INPUT_MYENDPOINT = 'EP1'
$env:ENDPOINT_URL_EP1 = 'https://[...]'
$env:ENDPOINT_AUTH_EP1 = '{ "Parameters": { "UserName": "Some user", "Password": "Some password" }, "Scheme": "Some scheme" }'
$env:ENDPOINT_DATA_EP1 = '{ "Key1": "Value1", "Key2": "Value2" }'
另请参阅: