Control options

To control the order of jobs, the dependsOn keyword can be used on the definition of a job. This signals that the job can only be started after one or more jobs are completed. Besides this, the condition keyword can be used to specify a condition that a job should run under. These two keywords can be combined to realize more complex scenarios, such as the one shown here:

jobs:
- job: compile
steps:
...
- job: test
dependsOn: compile
steps:
...
- job: build_schema
dependsOn: compile
steps:
..
- job: report
dependsOn:
- test
- build_schema
condition: or(succeeded('test'), succeeded('build_schema'))
steps:
..

This pipeline will start by running the job named compile. Once this job completes, the next two jobs, test and build_schema, will run in parallel as they both depend on the compile task. After both of these tasks complete, the report task runs as it declares a dependency on both the test and build_schema jobs. Before this job actually starts, the condition is evaluated to determine whether the job should actually run or be skipped. Conditions can be built using a syntax that is similar to many programming languages. It checks the successful completion of a job using the succeeded() and failed() functions. There is also support for Boolean operators such as or(), and(), and ne().

You can combine the dependsOn and condition keywords in any way you see fit. The only requirement is that there should be at least one job that does not depend on any other job.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset