【问题标题】:Azure DevOps: How to save KV variable into the common variableAzure DevOps:如何将 KV 变量保存到公共变量中
【发布时间】:2020-02-07 11:37:37
【问题描述】:

我在 Azure DevOps 中的管道执行以下操作:

  1. Bash 脚本:避免无法删除数据库的问题(Azure PostgreSQL: it is not possible to remove database through Azure CLI)

  2. Azure Key Vault:获取用于登录 PostgreSQL 数据库的 Key Vault 变量

  3. Azure CLI:使用 Azure CLI 删除数据库;
  4. NPM 安装:从 package.json 初始化 NodeJS 包
  5. NPM 运行:启动连接到 PostgreSQL 的 apply.js 文件,创建数据库,并使用 liquibase 应用架构;

apply.js 使用了一些环境变量,例如 DB_HOST,DB_PASSWORD, DB_USER,,它们存储在变量组中,但是,Key Vault 中的密码存储为 postgres-password 变量。所以,问题是如何将KV postgres-admin-password 变量保存到普通的DB_PASSWORD 变量中。

有什么办法吗?

【问题讨论】:

    标签: azure azure-devops azure-pipelines


    【解决方案1】:

    您可以添加一个 PowerShell 内联任务来设置 DB_PASSWORD 值,例如 postgres-admin-password

    Write-Host "##vso[task.setvariable variable=DB_PASSWORD;]$(postgres-admin-password)"
    

    【讨论】:

    • 感谢 Shayki 的帮助,这正是我想要的。
    猜你喜欢
    • 1970-01-01
    • 2021-07-14
    • 1970-01-01
    • 2021-11-23
    • 1970-01-01
    • 2020-07-24
    • 2022-11-29
    • 1970-01-01
    • 2020-09-27
    相关资源
    最近更新 更多