简体   繁体   English

将 output 传递给 azure 发布管道中的新作业

[英]Pass output to new job in azure release pipeline

I am looking for some help passing the output from a powershell script into another task in a release pipeline.我正在寻找一些帮助,将 output 从 powershell 脚本传递到发布管道中的另一个任务。

The workflow is as follows:工作流程如下:

在此处输入图像描述

I need to pass a variable that is created from the powershell script into the Manual intervention text message.我需要将从 powershell 脚本创建的变量传递到手动干预文本消息中。

In a yaml pipeline, I would use在 yaml 管道中,我会使用

  Write-Host "##vso[task.setvariable variable=myvar;isOutput=true]foo"

however in order to access this it only works if the previous task was a dependant, which I do not believe you can do in a release pipeline.但是,为了访问它,它仅在前一个任务是依赖项时才有效,我不相信您可以在发布管道中执行此操作。

I don't think that's true.我不认为那是真的。 In YAML pipelines, you can set variables at the root, stage, and job level.在 YAML 管道中,您可以在根、阶段和作业级别设置变量。 You can also use a variable group to make variables available across multiple pipelines.您还可以使用变量组使变量在多个管道中可用。 Some tasks define output variables, which you can consume in downstream steps, jobs, and stages .一些任务定义了 output 变量,您可以在下游步骤、作业和阶段中使用这些变量。

Coming to YAML, you can access variables across jobs and stages by using dependencies .来到 YAML,您可以使用dependencies跨作业和阶段访问变量。 By default, each stage in a pipeline depends on the one just before it in the YAML file.默认情况下,管道中的每个阶段都依赖于 YAML 文件中的前一个阶段。 If you need to refer to a stage that isn't immediately prior to the current one, you can override this automatic default by adding a dependsOn section to the stage.如果您需要引用一个不在当前阶段之前的阶段,您可以通过向阶段添加一个dependsOn部分来覆盖此自动默认值。

For example, let's assume we have a task called MyTask , which sets an output variable called MyVar .例如,假设我们有一个名为MyTask的任务,它设置了一个名为MyVar的 output 变量。 To use outputs in a different job:要在不同的作业中使用输出:

jobs:
 - job: A
  steps:
  # assume that MyTask generates an output variable called "MyVar"
  # (you would learn that from the task's documentation)
 - task: MyTask@1
    name: ProduceVar  # because we're going to depend on it, we need to name the step
 - job: B
  dependsOn: A
  variables:
    # map the output variable from A into this job
    varFromA: $[ dependencies.A.outputs['ProduceVar.MyVar'] ]
  steps:
 - script: echo $(varFromA) # this step uses the mapped-in variable

For more details on the syntax and examples, check the following articles:有关语法和示例的更多详细信息,请查看以下文章:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Azure DevOps 发布管道中控制作业顺序 - Control Job Order in Azure DevOps Release Pipeline 传递管道变量释放变量 Azure DevOps - Pass pipeline variable to release variable Azure DevOps Azure DevOps 发布管道门中的 Output 变量 - Output variables in Azure DevOps release pipeline gates Azure 发布管道 - 仅在 VM 可用时运行代理作业 - Azure Release Pipeline - Only run agent job if VM is available “Run this job” based on value in angular.json in Azure Release Pipeline - “Run this job” based on value in angular.json in Azure Release Pipeline Azure DevOps - 使用部署组或部署作业向环境发布管道? - Azure DevOps - Release Pipeline using Deployment Groups or Deployment Job to an Environment? 当 sourceFolder 包含 Azure 发布管道中的文件夹时,“运行此作业” - "Run this job" when sourceFolder contains a folder in Azure Release Pipeline 如何在发布管道中的 Azure DevOps 中输出 terraform 输出文件 - How to output terraform output file in Azure DevOps in release pipeline Azure DevOps 发布管道 - 将环境变量传递给 docker 容器 - Azure DevOps Release Pipeline - Pass environment variable to docker container 如何在Azure发布管道中跨代理作业使用输出变量 - How to use output variables across agent jobs in azure release pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM