gpt4 book ai didi

Azure Pipeline Secret 环境变量标记为未定义

转载 作者:行者123 更新时间:2023-12-02 07:23:14 24 4
gpt4 key购买 nike

当我将环境变量(管道 -> 库)标记为 secret 时,我似乎无法在管道运行中访问它。

例如,当我尝试访问该变量时,Node.js 将其标记为未定义

以下是我从 Azure Pipelines YAML 文件导入的代码:

variables:
- group: Foo-Bar-Variables

我有什么办法可以访问 secret 变量吗?我不想将它们存储为纯文本。

感谢您的帮助。

最佳答案

Is there any way for me to access the secret variables? I prefer to not store them as plain-text.

就像官方文档Set secret variables ,我们可以知道:

Each task that needs to use the secret as an environment variable does remapping. If you want to use a secret variable called mySecret from a script, use the Environment section of the scripting task's input variables. Set the environment variable name to MYSECRET, and set the value to $(mySecret).

- task: xxxx
displayName: 'xxxx'
env:
SOMEVAR: '$(TestVar)'
inputs:

此外,目前我们必须手动声明将在 yaml 文件中使用的所有 secret 变量。

希望这有帮助。

关于Azure Pipeline Secret 环境变量标记为未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60744591/

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