从github操作的变量中获取数组元素

发布于 2025-02-10 21:34:31 字数 327 浏览 0 评论 0原文

在GitHub Action File中,我正在运行AWS CLI命令,并存储使用Set-ouput的输出,并在下一步中重复使用它。

name: abc-name
id: abc
bash : |
   set-ouput name=opValue::$(aws ......command.....)

name: check
bash : echo ${{steps.abc.output.opValue}}

但是AWS命令的输出以数组的形式(例如“ value”),并且被存储在变量opvalue中。

在下一个“检查步骤”中,我只想获取它的值,而不是数组。

In github action file, I am running an AWS CLI command and storing the output of using set-ouput and reusing it in next step.

name: abc-name
id: abc
bash : |
   set-ouput name=opValue::$(aws ......command.....)

name: check
bash : echo ${{steps.abc.output.opValue}}

but the aws command's output is in the form of array like ["value"] and same is getting stored in variable opValue.

In my next "check step", I want to only fetch value of it, not the array.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

皇甫轩 2025-02-17 21:34:31

使用 jq 选择aws aws命令>命令输出和存储的第一个值仅作为输出:

set-ouput name=opValue::$(aws ......command..... | jq '.[0]')

Use jq to select the first value of the aws command output and store only that as output:

set-ouput name=opValue::$(aws ......command..... | jq '.[0]')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文