gpt4 book ai didi

azure - 使用破折号 (-) 作为参数中键名称的一部分

转载 作者:行者123 更新时间:2023-12-04 01:40:42 25 4
gpt4 key购买 nike

我正在创建一个 azure 管道作业,并希望使用all-features名称作为关键参数。它在 yaml 中有效,但看起来我无法在条件下使用它,或者以某种方式 azure 解析它错误。有可能让它发挥作用吗?

parameters:
all-features: false
name: cargo_check

jobs:
- job: ${{ parameters.name }}
pool:
vmImage: ubuntu-16.04
variables:
cliflags: ''
steps:
- template: ../steps/install-rust.yml
parameters:
rustup_toolchain: ${{ parameters.rust }}

- script: echo '##vso[task.setvariable variable=cliflags]$(cliflags) --all-features'
enabled: ${{ parameters.all-features }} ###### at this line I am getting error #######
displayName: "Activate all available features"

错误:

/ci/jobs/cargo-check.yml@templates (Line: 99, Col: 14): Unexpected symbol: 'all-features'. Located at position 12 within expression: parameters.all-features. For more help, refer to https://go.microsoft.com/fwlink/?linkid=842996

/ci/jobs/cargo-check.yml@templates (Line: 99, Col: 14): Unexpected value '${{ parameters.all-features }}'

解决方法是将名称从 paramters.all-features 更改为 parameters.all_features,但我喜欢使用破折号(-)。它将与命令行界面中的参数名称相同,在这种情况下我的观点是什么。

最佳答案

简短回答:

您可以使用 parameters['all-features'] 代替 parameters.all-features 并且它会起作用。

<小时/>

长答案:

Using dash(-) as part of key name in paramters (Azure pipelines)

对于给您带来的任何不便,我们深表歉意。

此行为是设计使然。经过一段时间的调查,但没有找到任何解决方法来解决这个问题。

正如文档Expressions统计数据:

Variables As part of an expression, you may access variables using one of two syntaxes:

  • Index syntax: variables['MyVar']
  • Property dereference syntax: variables.MyVar

In order to use property dereference syntax, the property name must:

  • Start with a-Z or _
  • Be followed by a-Z 0-9 or _

希望这对您有帮助。

关于azure - 使用破折号 (-) 作为参数中键名称的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57586664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com