SOLVED

Pass variable value to a job in a template from previous job

Brass Contributor

Hello,

 

This is my yaml  pipeline

 

stages:
- stage: 'build'
  displayName: 'Build'
  jobs:
  - job: 
    steps:
    - task: CmdLine@2
      name: 'calculateAppVersion'
      displayName: 'Calculate Chart  Versions'
      inputs:
        script: |
          chartVersion="abcd1234"          
          echo "##vso[task.setvariable variable=chartVersion;isOutput=true]$chartVersion"   
  - template: ./template-scan.yaml
    

 

 

This is my template-scan

 

jobs:
- job: 'scan'
  variables: 
    containerTag: $[ dependencies.${{parameters.dependentJob}}.outputs['setVariable.chartVersion'] ]
  steps:  
   .
   .
   .

 

 

I am unable to access the container Tag value. Its always blank in template. Does this approach of dynamically creating the variable and then reading it in another job within template works.. If not, can anyone suggest some solution.

 

Thank you.

 

Kind Regards,

Tanul

1 Reply
best response confirmed by tanulbhasin (Brass Contributor)
Solution
My mistake. It should be like this

calculateAppVersion.chartVersion
1 best response

Accepted Solutions
best response confirmed by tanulbhasin (Brass Contributor)
Solution
My mistake. It should be like this

calculateAppVersion.chartVersion

View solution in original post