【问题标题】:Azure Devops Predefined Variables - pass as parameterAzure Devops 预定义变量 - 作为参数传递
【发布时间】:2021-05-06 13:58:01
【问题描述】:

我在 Azure Devops Pipelines 中使用 NPM 运行任务。我想将 Azure 预定义变量传递到我的 package.json。

例如:npm run cypresstask

这样我就可以将其作为“cypress run --ci-build-id”的参数传递

【问题讨论】:

    标签: npm azure-devops cypress


    【解决方案1】:

    在您的 package.json 文件中,您可以在脚本中编写命令:

      "scripts": {
        "test": "cypress run --ci-build-id"
      }
    

    在你的 yml 文件中你可以使用:

    npm test
    

    【讨论】:

      【解决方案2】:

      回答我自己的问题:

      NPM 运行任务命令: 运行 cypress:ci --azbuildid=$(Build.BuildNumber)

      然后在 package.json 中,您可以将其提供为 赛普拉斯运行 --ci-build-id $npm_config_azbuildid

      所以你用 -- 设置参数。使用 $() 提供预定义变量并使用 $npm_config_ 在 package.json 中访问它们

      【讨论】:

      • 嗨@Steven,非常感谢您分享您的经验和答案。我建议您可以将自己的答案标记为该主题的解决方案。这可能对正在寻找类似问题的解决方案的人非常有帮助。谢谢。
      猜你喜欢
      • 1970-01-01
      • 2020-07-19
      • 1970-01-01
      • 2012-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多