# [[Gitlab CICD]] _Created: 2025-10-25_ | #cicd #gitlab | [[020 Programming MOC|Programming]] ## Stages [Reference](https://docs.gitlab.com/ci/yaml/#stages) If `stages` is not defined in the `.gitlab-ci.yml` file, the default pipeline stages are: - `.pre`: - You do not have to define `.pre` in stages. - `build` - `test` - `deploy` - `.post` - You do not have to define `.post` in `stages`. _If `stage` keyword in a job is not defined, the job uses the `test` stage by default._ The order of the items in `stages` defines the execution order for jobs: - Jobs in the same stage run in parallel. - Jobs in the next stage run after the jobs from the previous stage complete successfully. Important points: - If a pipeline contains only jobs in the `.pre` or `.post` stages, it does not run. There must be at least one other job in a different stage. - If a pipeline has jobs with [`needs: []`](https://docs.gitlab.com/ci/yaml/#needs) and jobs in the `.pre` stage, they will all start as soon as the pipeline is created. Jobs with `needs: []` start immediately, ignoring any stage configuration. - If any job fails, the pipeline is marked as `failed` and jobs in later stages do not start. _Jobs in the current stage are not stopped and continue to run._ - If a stage is defined but no jobs use it, the stage is not visible in the pipeline. ## Concurrency - Jobs can run in parallel if they run on different runners. - If you have only one runner, jobs can run in parallel if the runner’s [`concurrent` setting](https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-global-section) is greater than `1`. ### Using `needs` Use `needs` to execute jobs out-of-order. You can ignore stage ordering and run some jobs without waiting for others to complete. You should not combine `needs` with [`dependencies`](https://docs.gitlab.com/ci/yaml/#dependencies) in the same job. An empty array (`[]`) for `needs`, will start the job to start as soon as the pipeline is created. Regarding Artifacts - When a job uses `needs`, it no longer downloads all artifacts from previous stages by default, because jobs with `needs` can start before earlier stages complete. - With `needs` you can only download artifacts from the jobs listed in the `needs` configuration. - Use `artifacts: true` (default) or `artifacts: false` to control when artifacts are downloaded in jobs that use needs.