如何将Powershell脚本变量值传递到Release管道中的下游任务 [英] How to pass powershell script variable values to downstream task in Release pipeline

查看:144
本文介绍了如何将Powershell脚本变量值传递到Release管道中的下游任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从"Azure PowerShell任务"开始,只需几步就可以创建CD.

Created a CD with few steps starting from "Azure PowerShell Task".

在Azure PowerShell任务中,执行PowerShell脚本文件并在变量中设置一个值. 在脚本的最后,我为变量设置了一个值–

In Azure PowerShell tasks, executing a PowerShell script file and set a value in a variable. At the end of the script I have set the variable with a value –

echo "##vso[task.setvariable variable=myvariable;isSecret=false;isOutput=true;]myvalue"

myvariable 是变量

myvalue 是值.

基于"myvariable"的值;下游任务将被执行或跳过.在下游任务(任务-Azure创建或更新资源)中提到自定义条件" –

Based on the value of "myvariable"; downstream task will be executed or skipped. Mentioned "Custom Condition" in downstream task (Task - Azure Create or Update Resource) –

and(succeeded(), eq(variables[‘myvariable’], ‘myvalue’))

但是,它总是跳过这一步;尽管传递了正确的值.这是我的发布任务代码段-

But, it’s always skipping the step; despite the correct value is passing. Here is my release tasks snippet -

我该如何克服?

推荐答案

尝试

Write-Host "##vso[task.setvariable variable=myvariable;isSecret=false;isOutput=true;]myvalue"

然后

and(succeeded(), eq(variables['myvariable'], 'myvalue'))

在第二部分中,您粘贴的代码具有不正确的引号类型,您使用的是弯引号",而不是普通的直接引号"

In the second part, the code you pasted in has the incorrect quote types, you had curly quotes ‘ ’ rather than the normal straight quotes ' '

如果从Word或Outlook复制/粘贴,通常会出现错误的引号.我敢肯定他们有一个合适的印刷术术语.

You often end up with the wrong quotes if copying / pasting from Word or Outlook. I'm sure there's a proper a typography term for them.

这篇关于如何将Powershell脚本变量值传递到Release管道中的下游任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆