简体   繁体   中英

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?

在此处输入图像描述

You should use logging command if you want to assign powershell variable to Azure DevOps variable

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.

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.

However, these are two ways of doing that.

You can use two methods:

  1. $NewIP = $(pipeline_ip) Macro syntax variables
  2. $NewIP = $env:PIPELINE_IP Set variables in pipeline

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM