In my yaml pipeline I have multiple jobs which are dependent on each other. However in one of the jobs when I define the condition, I am getting the following error:
Unexpected symbol: ')'. Located at position 53 within expression: and(not(or(failed('Unittests'), canceled('Unittests'))), not(canceled('Check_Requirements'))). For more help, refer to https://go.microsoft.com/fwlink/?linkid=842996
This is how I defined the job which is showing the error:
- job: Security_Check
displayName: "Security Check"
dependsOn:
- Check_Requirements
- Unittests
condition: and(not(or(failed('Unittests'), canceled('Unittests'))), not(canceled('Check_Requirements')))
pool:
name: "Basic_Pool_Ubuntu"
variables:
- name: foundVuls
value: $[ dependencies.Check_Requirements.outputs['CheckVuls.foundVul'] ]
- name: Artifact.Folder
value: "artifacts"
I want the Job to run when the Job 'Unittests' has not failed or cancelled and the job 'Check_Requirement' has not failed.
Does anyone know what am I doing wrong here. I tried multiple ways to define this condition but always got the "Unexpected symbol: ')'" Error
Based on your YAML sample, I can reproduce the same issue.
I want the Job to run when the Job 'Unittests' has not failed or cancelled and the job 'Check_Requirement' has not failed.
To meet your requirement, you can use the following condition:
condition: and(notIn(dependencies.Unittests.result, 'failed', 'canceled'), ne(dependencies.Check_Requirements.result, 'canceled'))
YAML Sample:
- job: Security_Check
displayName: "Security Check"
dependsOn:
- Check_Requirements
- Unittests
condition: and(notIn(dependencies.Unittests.result, 'failed', 'canceled'), ne(dependencies.Check_Requirements.result, 'canceled'))
pool:
name: "Basic_Pool_Ubuntu"
variables:
- name: foundVuls
value: $[ dependencies.Check_Requirements.outputs['CheckVuls.foundVul'] ]
- name: Artifact.Folder
value: "artifacts"