79089633

Date: 2024-10-15 11:08:17
Score: 1
Natty:
Report link

Based on the feedback of @George Kosmidis to the answer of the original demander himself, I propose the following solution to decouple the hard dependency from the template to the calling pipeline:

--- template ---

parameters:
  - name: dependentStage
    type: string
stages:
  - stage: Stage3
    variables:
      foo3: $[ stageDependencies.${{ parameters.dependentStage}}.Job1.outputs['step1.bar'] ]
    dependsOn: [Stage1]
    jobs:
      - job:
        steps:
          - script: echo $(foo3)

--- main pipeline

stages:
  - stage: Stage1
    jobs:
      - job: Job1
        steps:
          - task: powershell@2
            inputs:
              filePath: Tests/LoadData.ps1

          - script: echo $(foo)
            displayName: read foo

          - bash: echo "##vso[task.setvariable variable=bar;isOutput=true]$(foo)"
            name: step1
            displayName: create public variable

  - template: myTemplate.yml
    parameters:
      - dependentStage: Stage1
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @George
  • Low reputation (1):
Posted by: Chengbin XIA