Azure DevOps Pipeline define variable in deployment and reuse in subsequent job

0 votes

I wanted to pass a variable value from a deployment job to a subsequent job that depends on it.

Here is my complete test pipeline (almost entirely copied from here):

trigger: none

stages:
  - stage: X
    jobs:
      - deployment: A
        pool:
          vmImage: "ubuntu-16.04"
        environment: test
        strategy:
          runOnce:
            deploy:
              steps:
                - script: echo "##vso[task.setvariable variable=myOutputVar;isOutput=true]this is the deployment variable value"
                  name: setvarStep
                - script: echo $(setvarStep.myOutputVar)
                  name: echovar

      - job: B
        dependsOn: A
        pool:
          vmImage: "ubuntu-16.04"
        variables:
          myVarFromDeploymentJob: $[ dependencies.A.outputs['deploy.setvarStep.myOutputVar'] ]
        steps:
          - script: "echo $(myVarFromDeploymentJob)"
            name: echovar


How can I pass a variable from a runOnce deployment job to a regular job?
Apr 8, 2022 in Other DevOps Questions by Kichu
• 19,050 points
737 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Other DevOps Questions

0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP