Azure Devops deployment pipeline: access output variable in different job

3.7k views Asked by At

Using Azure Devops 2019 Server (On-Premises)

So I want my agentless job, User Intevention task named "Install" to run only when IsServiceInstalled variable is 0. I'm able to use this variable only within same job (agent), but not within other (agentless). enter image description here

No matter what I do, I get an exception stating something like:

Exception Message: Unrecognized value: 'dependencies'. Located at position 21 within expression: and(succeeded(), eq(<whatever i try to put here>, 0))

Code that sets variable:

#Sets IsServiceInstalled to determine if service must be installed or updated

Get-Service "$(RabbitMQServiceName)" -ErrorAction SilentlyContinue
if ($?) {
  echo "##vso[task.setvariable variable=IsServiceInstalled;isOutput=true]1"
} else {
  echo "##vso[task.setvariable variable=IsServiceInstalled;isOutput=true]0"
}

Task itself: enter image description here

  1. I'm aware that I can use "depdendencies." to access that variable. Use the output variable from a job in a condition in a subsequent job. But I don't get an option to name Job.
  2. I'v ran my deployment with system.debug=true and found out [SYSTEM_JOBNAME] --> [__default] - so I tried setting using and(succeeded(), eq(dependencies.__default.Outputs['IsServiceInstalledTask.IsServiceInstalled'], 0)) - yeah, I get exception Unrecognized value: 'dependencies' - and no surprise as I never specified a dependency and I don't see where can I specify it within UI.
  3. I don't have an option to set Job Name, so i'v tried setting various values I found within debug log (__default being the jobname I want my output variable from): Stage_cb7edb91b40b4747845ae3564bf62723_2_9.Phase_1.__default..., Phase_1.__default... or __default...

No matter what I try, I get the same Unrecognized value exception.

1

There are 1 answers

0
Janis Veinbergs On BEST ANSWER

The great thing about writing a question is that I'v found the answer in official documentation: NOT SUPPORTED in classic pipeline.

Let me quote:

Use output variables from tasks

Some tasks define output variables, which you can consume in downstream steps, jobs, and stages. In YAML, you can access variables across jobs and stages by using dependencies..

Use outputs in the same job

In the Output variables section, give the producing task a reference name. Then, in a downstream step, you can use the form $(.) to refer to output variables.

Use outputs in a different job

You must use YAML to consume output

From Use output variables from tasks and click on Classic Tab