azure-pipelines

Share and Use Variables between Agent job and agentless job in Azure Classic Release pipelines


Note: We are using Classic Azure DevOps Release pipeline

We have an agent job does two app service deployment Next step is a Agentless manual intervention

We don't need to run this Agentless Manual intervention to run on 2 condition:

  1. 'ManualValidation' variable in variable group is true
  2. IF the task2 in Agent job is success

Otherwise we don't need to run the agentless manual intervention and it needs to be failed status so that next Agent-2 job should not run it has condition (Only when all the previous jobs succeeded)

**********Clarification ***********

  1. Since its a classic pipeline, I believe cannot use a output variable.

    How do I check two values in variable condition in Agentless job, is there any property will say that last task from previous job failed and accessible in Agent job so that I can use in and condition with variables?

  2. What if the Task2 in Agent-Job1 fails. Will it stop running the AgentJob-2 tasks since it has condition (Only when all the previous jobs succeeded)

- AgentJob-1
    Task1
    Task2
 
- Agentless Job 
  condition: (eq(variables['ManualValidation'],'true')
    Manual Intervention Task

 - AgentJob-2
     Task1
     Task2

Solution

  • I couldn't find any way to pass variables from agent job to agentless job in classic pipeline

    My requirement is execute the agentless only

    1. if all the tasks in inAgentjob-1 succeed and library variable "ManualValidation" is true

    2. it has to skip Agentless job or should not run

    if any of tasks in inAgentjob-1 fails && "ManualValidation"== true This will in turn skips the Agentjob-2 from running

    So instead of variable passing from the Agent job , found some thing in Microsoft articles

    added a variable expression like below and it seems to be working

    and(succeeded(),eq(variables['ManualValidation'],'true'))
    
    - Agentjob-1 
        Task-1
       Task-2
    
    - Agentlessjob 
    
            
    - Agentjob-2 
        Task-1
        Task-2