将输出变量传递到不同的阶段
Pass output variable to different stages
我在 Azure DevOps 中有一个管道,基本上看起来像这样
stage: BuildStage
job: SetUp
job: Compile
stage: DeployStage
job: Deploy
在 SetUp
作业中,我定义了一个输出变量,我可以在 Compile
作业中使用
来定义它
variables:
MyVariableFromSetUp: $[ dependencies.SetUp.outputs['MyVariable'] ]
问题是,如何在部署作业中执行相同的操作?我不想 运行 SetUp 阶段两次,因为计算 MyVariable
的值非常耗时,因此我必须缓存它。
DeployStage 依赖于 BuildStage,但我似乎无法按预期使用 dependencies
。文档在处理变量时没有提到多阶段的情况。
嘿,根据我的发现,目前没有直接的方法可以做到这一点,您将遵循以下 3 种方法之一
使用此方法将其作为工件值传递https://medium.com/microsoftazure/how-to-pass-variables-in-azure-pipelines-yaml-tasks-5c81c5d31763
使用 VSTeam powershell 模块通过 API 端点传递它 https://www.donovanbrown.com/post/Passing-variables-from-stage-to-stage-in-Azure-DevOps-release, similar method can also be found here https://stefanstranger.github.io/2019/06/26/PassingVariablesfromStagetoStage/
我在 Azure DevOps 中有一个管道,基本上看起来像这样
stage: BuildStage
job: SetUp
job: Compile
stage: DeployStage
job: Deploy
在 SetUp
作业中,我定义了一个输出变量,我可以在 Compile
作业中使用
variables:
MyVariableFromSetUp: $[ dependencies.SetUp.outputs['MyVariable'] ]
问题是,如何在部署作业中执行相同的操作?我不想 运行 SetUp 阶段两次,因为计算 MyVariable
的值非常耗时,因此我必须缓存它。
DeployStage 依赖于 BuildStage,但我似乎无法按预期使用 dependencies
。文档在处理变量时没有提到多阶段的情况。
嘿,根据我的发现,目前没有直接的方法可以做到这一点,您将遵循以下 3 种方法之一
使用此方法将其作为工件值传递https://medium.com/microsoftazure/how-to-pass-variables-in-azure-pipelines-yaml-tasks-5c81c5d31763
使用 VSTeam powershell 模块通过 API 端点传递它 https://www.donovanbrown.com/post/Passing-variables-from-stage-to-stage-in-Azure-DevOps-release, similar method can also be found here https://stefanstranger.github.io/2019/06/26/PassingVariablesfromStagetoStage/