Forum Discussion
Guhanath
Feb 02, 2023Copper Contributor
One plugin task status as condition in another plugin task
Hello, We have two Azure Plugin extensions (created using nodejs) to be used in our pipeline and they needs to be dependent. Review task is at CI stage, Publish task is at CD stage sample code as ...
2MuchC0ff33
Feb 02, 2023Brass Contributor
Hi thereGuhanath
Answer 1: You can set the condition for each task to always run to make both tasks mandatory. For the ReviewAPI task, for example:
- task: ReviewAPI
displayName: do review for my API
inputs: <parameters>
condition: always()In addition, for the publishAPI task:
- task: publishAPI
displayName: publish my API
inputs: <parameters>
condition: always()Answer 2: A condition in the publishAPI task can be added to validate that the ReviewAPI task was completed. To check the status of the ReviewAPI task, use the succeeded() function:
- task: publishAPI
displayName: publish my API
inputs: <parameters>
condition: succeeded('ReviewAPI')Answer 3: Yes, an artifact/output variable can be created in the ReviewAPI task and validated in the publishAPI task. You can follow the steps. The name of the step is>. outputs syntax for accessing a previous task's output variables:
# ReviewAPI task
- task: ReviewAPI
displayName: do review for my API
inputs: <parameters>
outputs:
reviewResult: true
# publishAPI task
- task: publishAPI
displayName: publish my API
inputs: <parameters>
condition: eq(steps.ReviewAPI.outputs['reviewResult'], 'true')
Reference:
- https://docs.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops
- https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml