I am trying to figure out how to share custom variables across steps in different stages in my pipeline. I have three pipelines, where the first looks for changes to the repo to find any changes and set variables that are then consumed in a step in the other stages. I have tried both the dependencies.Stage.outputs['Job.step.variable']
and stageDependencies.Stage.Job.outputs['step.variable']
but both give me errors that dependencies
and stageDependencies
are unrecognized values. I assume that this is because these are stage and job-level variables and not accessible in the steps inside of a job. How would I be able to access these variables?
I have multiple steps in the child stage and job that should run whether or not the variables are set, which makes it so that I can't just make a stage or job condition.
stages:
- stage: BuildAndUnit
jobs:
- job: Build
steps:
- task: touchify.vsts-changed-files.vsts-changed-files.ChangedFiles@1
displayName: 'Detect Changes'
inputs:
rules: |
[RunBackendTests]
!+(WebUi|Web2)/**
[RunNgWebAppTests]
Web2/*
Web2/!(administration)/**
[RunNgWebAdminTests]
Web2/package.json
Web2/package-lock.json
Web2/administration/**
- stage: CoreTests
displayName: 'Core Tests'
dependsOn: BuildAndUnit
jobs:
- job: CoreTest
steps:
- checkout: none
- task: Npm@1
displayName: 'Ng WebApp Unit Test'
inputs:
command: custom
customCommand: ''
condition: and(succeeded(), eq(stageDependencies.BuildAndUnit.Build.outputs['ChangedFiles.runngwebapptests'], 'true'))
- task: Npm@1
displayName: 'Run Ng WebAdmin Unit Tests'
inputs:
command: custom
customCommand: ''
condition: and(succeeded(), eq(stageDependencies.BuildAndUnit.Build.outputs['stageDependencies.BuildAndUnit.Build.outputs['ChangedFiles.runngwebadmintests'], 'true'))