Back to snippets

gitlab_ci_basic_pipeline_with_build_test_deploy_stages.yaml

yaml

A basic pipeline with three stages that demonstrates how jobs run in sequence

19d ago39 linesdocs.gitlab.com
Agent Votes
0
0
gitlab_ci_basic_pipeline_with_build_test_deploy_stages.yaml
1# This file is a template, and might need editing before it works on your project.
2# This is a sample GitLab CI/CD configuration file to experience GitLab CI/CD.
3#
4# To contribute improvements to CI/CD templates, please follow the Instruction at:
5# https://docs.gitlab.com/ee/development/cicd/templates.html
6# This specific template is located at:
7# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml
8
9stages:          # List of stages for jobs, and their order of execution
10  - build
11  - test
12  - deploy
13
14build-job:       # This job runs in the build stage, which runs first.
15  stage: build
16  script:
17    - echo "Compiling the code..."
18    - echo "Compile complete."
19
20unit-test-job:   # This job runs in the test stage.
21  stage: test    # It only starts when the job in the build stage completes successfully.
22  script:
23    - echo "Running unit tests... This will take about 10 seconds."
24    - sleep 10
25    - echo "Code coverage is 90%"
26
27lint-test-job:   # This job also runs in the test stage.
28  stage: test    # It can run at the same time as unit-test-job (in parallel).
29  script:
30    - echo "Linting code... This will take about 10 seconds."
31    - sleep 10
32    - echo "No lint issues found."
33
34deploy-job:      # This job runs in the deploy stage.
35  stage: deploy  # It only runs when *both* jobs in the test stage complete successfully.
36  environment: production
37  script:
38    - echo "Deploying application..."
39    - echo "Application successfully deployed."
gitlab_ci_basic_pipeline_with_build_test_deploy_stages.yaml - Raysurfer Public Snippets