如何在Azure DevOps管道中使用JSON变量 [英] How to use JSON variables in an Azure DevOps pipeline

查看:52
本文介绍了如何在Azure DevOps管道中使用JSON变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这是否可行,因为我进行了搜索,但找不到任何相关内容,但是没有发现任何不正确的内容!

I'm not sure if this is possible as I've searched but couldn't find anything related, but didn't find anything saying it's not!

在我的Azure DevOps构建管道中,我有一个变量,该变量保存一个JSON值,例如:

In my Azure DevOps build pipeline I have a variable which holds a JSON value e.g:

是否在任务中使用json变量的值?我已经尝试过(偶然) $(myJson.message) $(myJson).message ,但是这些都不起作用.

Is there anyway of using a value of a json variable within a task? I've tried (on the off chance) $(myJson.message) and $(myJson).message but these didn't work.

那么管道变量仅支持简单类型吗?还是有办法解决这个问题?

So do pipeline variables only support simple types? Or is there a way round this?

推荐答案

您总是可以使用powershell的 Convert-FromJson 之类的东西来创建json对象,但是无法告诉随机任务将此变量值视为对象,而不是原始字符串".您必须自己解析.

You could always use something like powershell's Convert-FromJson to create a json object, but there's no way to tell a random task "treat this variable value as an object, rather than a raw string". You'll have to parse it yourself.

这篇关于如何在Azure DevOps管道中使用JSON变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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