简体   繁体   English

将 Azure Powershell 变量分配给 DevOps 管道变量

[英]Assign Azure Powershell variable to DevOps Pipeline variable

How can I assigned the $NewIP variable precalculated in this step to a DevOps pipeline variable called $pipeline_ip?如何将在此步骤中预先计算的 $NewIP 变量分配给名为 $pipeline_ip 的 DevOps 管道变量?

在此处输入图像描述

You should use logging command if you want to assign powershell variable to Azure DevOps variable如果要将 powershell 变量分配给 Azure DevOps 变量,则应使用日志记录命令

echo "##vso[task.setvariable variable=pipeline_ip;]$NewIP"

Update after clarification:澄清后更新:

If you use syntax like:如果您使用如下语法:

$NewIP = $(pipeline_ip) Then $(pipeline_ip) would be replaced with the value before script will be executed. $NewIP = $(pipeline_ip)然后$(pipeline_ip)将被替换为执行脚本之前的值。

And if you use syntax like如果你使用类似的语法

$NewIP = $env:PIPELINE_IP then you will refer to environment variable and since all DevOps variables are mapped (except secret variables - here you need to express this excplicitly) it would also work. $NewIP = $env:PIPELINE_IP然后您将引用环境变量,并且由于所有 DevOps 变量都已映射(秘密变量除外 - 在这里您需要明确表达)它也可以工作。

However, these are two ways of doing that.但是,这是这样做的两种方法。

You can use two methods:您可以使用两种方法:

  1. $NewIP = $(pipeline_ip) Macro syntax variables $NewIP = $(pipeline_ip) 宏语法变量
  2. $NewIP = $env:PIPELINE_IP Set variables in pipeline $NewIP = $env:PIPELINE_IP 在管道中设置变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Azure Devops 发布管道中使用 PowerShell 设置环境变量? - How to set an environment variable with PowerShell in Azure Devops release pipeline? Azure DevOps 管道 - 带管道变量的条件表达式 - Azure DevOps Pipeline - condition expression with pipeline variable Azure devops 变量组在 powershell - Azure devops variable groups in powershell 传递管道变量释放变量 Azure DevOps - Pass pipeline variable to release variable Azure DevOps 在运行 Azure DevOps 管道时,如果我们不给管道的 powershell 脚本中使用的变量任何值 - While running Azure DevOps pipeline, If we dont give any value to the variable which is used in powershell script of pipeline 如何将变量传递给 Azure DevOps 运行管道 - How to pass variable to Azure DevOps Run Pipeline 从 azure devops 管道更新变量组 - update variable group from azure devops pipeline Azure DevOps 发布管道变量值未更新 - Azure DevOps Release Pipeline Variable Values are not updating Azure 任务步骤名称的 devops 管道变量 - Azure devops pipeline variable for a task step name 将变量值从 Powershell 任务中的一个脚本传递到 Azure DevOps 发布管道中下一个 Powershell 任务中的另一个脚本 - Pass variable value from one Powershell script in Powershell task to another script in the next Powershell task in Azure DevOps Release Pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM