jobs:
# Set an output variable from job A
- job: A
steps:
- powershell: |
$image_infor=Invoke-WebRequest https://raw.githubusercontent.com/Sitecore/docker-images/master/tags/sitecore-tags.json ###json data
Write-Host $image_infor
Write-Host "##vso[task.setvariable variable=myOutput_currentDate;isoutput=true]$image_infor"
name: setvarStep
# Map the variable into job B
- job: B
dependsOn: A
variables:
myVarFromJobA: $[ dependencies.A.outputs['setvarStep.myOutput_currentDate'] ]
steps:
- powershell: |
Write-Host $myVarFromJobA.Name
this is the issue i have been facing. The content of the variable $image_infor does not not get passed to the second job. It appears blank without an error. So when i look at the logs for job A i can actuall see the value of the $image_infor but it does not get to job B .
Any help on that please.
expecting to seet the json value in job B
2
Answers
Several points need to be pay attentions.
isoutput
should beisOutput
$myVarFromJobA.Name
should be$(myVarFromJobA)
I have coded a sample with a tiny json data size.
Assuming you would only expect to use the Content of the web request to define the output variable rather than to output the whole
response
, please reference the sample YAML pipeline below.In job
A
, we should first convert the json value retrived from the.json
file to a one-line json string in order to pass it to downstream job; in jobB
we need to convert the output json string back to an object, so that we can extract the value referencing the object key name; in addition, we should add brackets$( variable )
to use the output variable in script.See for information in Set variables in scripts – Azure Pipelines | Microsoft Learn