3. Controlling Job Execution Flow
Introduction
This section will build upon the simple pipeline and show how job execution order can be modified to optimize the speed of execution for the overall pipeline.
Execution Order
-
1. In your demo project, find the 3-execution-order
branch inCode > Branches
-
2. Next to the branch name, click New
to create a new Merge Request from this branch -
3. Click Create Merge Request
-
4. Review the changes to the .gitlab-ci.yml file: - A new job,
code_quality
, has been added to thetest
stage. This job uses theneeds
keyword with an empty array ([]
) which specifies that the job can run independently of any previous job completion (i.e, thebuild_app
job). - Without the needs keyword, the
code_quality
job would not execute until all jobs in thebuild
stage are completed. - Additionally, another new job
run_app
has been added along with a newrun
stage. This job uses theneeds
keyword and specifies that it can execute once thebuild_app
job completes. With this specification, the job does not need to wait on any jobs in thetest
stage to complete. This represents a simple directed acyclic graph.- In a following section, we will add configurations for the
run_app
job to use the build artifact from thebuild_app
job
- In a following section, we will add configurations for the
- A new job,
-
5. Within the Merge Request, click Mark as Ready
in the Overview tab (if prompted), then clickMerge
. This will trigger a new pipeline using the newly added configurations to the .gitlab-ci.yml file. -
6. In the left hand navigation menu, click Build
->Pipelines
, then click the link for the most recently ran pipeline (ex: #577244133) to view the status of the pipeline. -
7. Click "Job Dependencies" next to "Group Jobs By", then toggle "Show Dependencies". Observe the dependency between the build_app
job and therun_app
job, as well as the grouping of jobs between columns that is implicitly defined by the flow of stages.