[英]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.