admin管理员组文章数量:1277384
I'm working on an Azure DevOps
Pipeline, and I'm having an issue where I'm unable to pass an output variable from a deployment job to a subsequent stage. Here's a simplified version of my pipeline YAML
:
trigger:
- master
pool:
vmImage: windows-latest
stages:
- stage: Deploy
jobs:
- deployment: DeployJob
environment:
name: 'Local VM Deployment'
resourceName: 'Resource-1'
resourceType: VirtualMachine
strategy:
runOnce:
deploy:
steps:
- task: PowerShell@2
name: SetDeployResult
inputs:
targetType: 'inline'
script: |
Write-Host "Setting output variable"
Write-Host "##vso[task.setvariable variable=DeployResult;isOutput=true]success"
- stage: PostDeployment
dependsOn: Deploy
jobs:
- job: PostDeployJob
variables:
deployResult: $[ dependencies.Deploy.outputs['DeployJob.Deploy_Resource1.SetDeployResult.DeployResult'] ]
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Write-Host "The deploy result from the Deploy stage is $(deployResult)"
displayName: 'Use Output Variable from Deploy Stage'
Problem:
In the PostDeployment stage, I’m trying to access the output variable DeployResult from the Deploy stage using the expression:
deployResult: $[ dependencies.Deploy.outputs['DeployJob.Deploy_Resource1.SetDeployResult.DeployResult'] ]
However, I am getting the following output:
Job preparation parameters
Variables:
deployResult:
Parsing expression: <dependencies.Deploy.outputs['DeployJob.Deploy_Resource1.SetDeployResult.DeployResult']>
Evaluating: dependencies['Deploy']['outputs']['DeployJob.Deploy_Resource1.SetDeployResult.DeployResult']
Expanded: Null
Result: ''
It seems that the output variable DeployResult is not being set correctly, or there's an issue with how I'm referencing it. Could someone help me understand why this variable is not being passed correctly from the deployment job to the PostDeployment stage?
I'm working on an Azure DevOps
Pipeline, and I'm having an issue where I'm unable to pass an output variable from a deployment job to a subsequent stage. Here's a simplified version of my pipeline YAML
:
trigger:
- master
pool:
vmImage: windows-latest
stages:
- stage: Deploy
jobs:
- deployment: DeployJob
environment:
name: 'Local VM Deployment'
resourceName: 'Resource-1'
resourceType: VirtualMachine
strategy:
runOnce:
deploy:
steps:
- task: PowerShell@2
name: SetDeployResult
inputs:
targetType: 'inline'
script: |
Write-Host "Setting output variable"
Write-Host "##vso[task.setvariable variable=DeployResult;isOutput=true]success"
- stage: PostDeployment
dependsOn: Deploy
jobs:
- job: PostDeployJob
variables:
deployResult: $[ dependencies.Deploy.outputs['DeployJob.Deploy_Resource1.SetDeployResult.DeployResult'] ]
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Write-Host "The deploy result from the Deploy stage is $(deployResult)"
displayName: 'Use Output Variable from Deploy Stage'
Problem:
In the PostDeployment stage, I’m trying to access the output variable DeployResult from the Deploy stage using the expression:
deployResult: $[ dependencies.Deploy.outputs['DeployJob.Deploy_Resource1.SetDeployResult.DeployResult'] ]
However, I am getting the following output:
Job preparation parameters
Variables:
deployResult:
Parsing expression: <dependencies.Deploy.outputs['DeployJob.Deploy_Resource1.SetDeployResult.DeployResult']>
Evaluating: dependencies['Deploy']['outputs']['DeployJob.Deploy_Resource1.SetDeployResult.DeployResult']
Expanded: Null
Result: ''
It seems that the output variable DeployResult is not being set correctly, or there's an issue with how I'm referencing it. Could someone help me understand why this variable is not being passed correctly from the deployment job to the PostDeployment stage?
Share Improve this question asked Feb 24 at 6:21 Afnan AshrafAfnan Ashraf 3163 silver badges16 bronze badges1 Answer
Reset to default 1Change to like as below which can work as expected:
stages:
- stage: Deploy
jobs:
- deployment: DeployJob
environment:
name: 'Local VM Deployment'
resourceName: 'Resource-1'
resourceType: VirtualMachine
strategy:
runOnce:
deploy:
steps:
- pwsh: |
Write-Host "Setting output variable"
Write-Host "##vso[task.setvariable variable=DeployResult;isOutput=true]success"
name: SetDeployResult
- stage: PostDeployment
dependsOn: Deploy
jobs:
- job: PostDeployJob
variables:
deployResult: $[ stageDependencies.Deploy.DeployJob.outputs['Deploy_Resource-1.SetDeployResult.DeployResult'] ]
steps:
- checkout: none
- pwsh: |
Write-Host "The deploy result from the Deploy stage is $(deployResult)."
displayName: 'Use Output Variable from Deploy Stage'
Related documentations:
- Deployment jobs
- Expressions
本文标签: Azure DevOps Pipeline Passing variables from a deployment job to another stageStack Overflow
版权声明:本文标题:Azure DevOps Pipeline: Passing variables from a deployment job to another stage - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741290379a2370514.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论