【问题标题】:Pass output variable to different stages将输出变量传递到不同的阶段
【发布时间】:2020-04-08 11:11:35
【问题描述】:

我在 Azure DevOps 中有一个管道,基本上看起来像这样

stage: BuildStage
   job: SetUp
   job: Compile
stage: DeployStage
   job: Deploy

SetUp 作业中,我定义了一个输出变量,我可以在Compile 作业中使用例如

variables:
   MyVariableFromSetUp: $[ dependencies.SetUp.outputs['MyVariable'] ]

问题是,我怎样才能在 Deploy 作业中做同样的事情?我不想运行两次设置阶段,因为计算MyVariable 的值很耗时,因此我必须缓存它。

DeployStage 对 BuildStage 有一个dependsOn,但似乎我无法按预期使用dependencies。在处理变量时,文档没有提到多阶段的情况。

【问题讨论】:

    标签: azure-devops multistage-pipeline


    【解决方案1】:

    嘿,根据我的发现,目前没有直接的方法可以做到这一点,您将遵循以下 3 种方法之一

    1. 使用此方法将其作为工件值传递https://medium.com/microsoftazure/how-to-pass-variables-in-azure-pipelines-yaml-tasks-5c81c5d31763

    2. 使用VSTeam powershell模块https://www.donovanbrown.com/post/Passing-variables-from-stage-to-stage-in-Azure-DevOps-release通过API端点传递它,类似的方法也可以在这里找到https://stefanstranger.github.io/2019/06/26/PassingVariablesfromStagetoStage/

    【讨论】:

    • 谢谢,这也是我找到的。我只是想确认我没有错过任何东西。我猜在 MS 决定添加这个之前,必须做人工制品(感觉像是一个遗漏)。
    猜你喜欢
    • 2021-05-22
    • 1970-01-01
    • 2019-09-14
    • 1970-01-01
    • 2020-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-04
    相关资源
    最近更新 更多