I'm writing a multi-stage job in Azure Pipelines that involves generating a matrix from a script as an output of a stage. I want to use that matrix across multiple stages to generate jobs, but I want to use conditions on jobs from a previous stage using that matrix.
Example azure-pipelines.yml:
stages:
- stage: A
jobs:
- job: generateMatrix
- stage: B
dependsOn: A
jobs:
- job: "" # This lets the job name be just the name of the matrix key
continueOnError: true # steps in these jobs may or may not fail
strategy:
matrix: $[ stageDependencies.A.generateMatrix.outputs['matrix'] ]
- stage: C
dependsOn: # Needs A's matrix and B job results
- A
- B
jobs:
- job: "" # The job name here should be the same as in stage B
continueOnError: true
strategy:
matrix: $[ stageDependencies.A.generateMatrix.outputs['matrix'] ]
steps:
- script: echo "Job from Stage B Succeeded"
condition: eq(stageDependencies.B.variables['Agent.JobName'].result, 'Succeeded')
- script: echo "Job from Stage B Failed"
condition: condition: ne(stageDependencies.B.variables['Agent.JobName'].result, 'Succeeded')
So I need to be able one of the following:
- Be able to parameterize the json path inside the stage dependencies
- Be able to edit and add a variable to the existing matrix in Stage (B) and somehow output that.
Does anyone have any idea on how to do this? I tried the above but it failed.
json { "foo": {"var1": "val1"}, ... }
and I want to add another value into that matrix such thatjson { "foo": {"var1": "val1", "var2": "val2"}, ... }
– user105189