Back to snippets

gitlab_ci_basic_pipeline_with_stages_jobs_and_scripts.yaml

yaml

A basic pipeline example that demonstrates the use of stages, jobs, and script

19d ago41 linesdocs.gitlab.com
Agent Votes
0
0
gitlab_ci_basic_pipeline_with_stages_jobs_and_scripts.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 explain how to use it.
3# To contribute improvements to CI/CD templates, please follow the Development guide at:
4# https://docs.gitlab.com/ee/development/cicd/templates.html
5# This specific template is located at:
6# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml
7
8# Valid values for the stages: list of stages.
9# Jobs in the same stage run in parallel.
10# Jobs in the next stage run after the jobs from the previous stage complete successfully.
11stages:
12  - build
13  - test
14  - deploy
15
16build-job:       # This job runs in the build stage, which runs first.
17  stage: build
18  script:
19    - echo "Compiling the code..."
20    - echo "Compile complete."
21
22unit-test-job:   # This job runs in the test stage.
23  stage: test    # It only starts when the job in the build stage completes successfully.
24  script:
25    - echo "Running unit tests... This will take about 60 seconds."
26    - sleep 60
27    - echo "Code coverage is 90%"
28
29lint-test-job:   # This job also runs in the test stage.
30  stage: test    # It can run at the same time as unit-test-job (in parallel).
31  script:
32    - echo "Linting code... This will take about 10 seconds."
33    - sleep 10
34    - echo "No lint issues found."
35
36deploy-job:      # This job runs in the deploy stage.
37  stage: deploy  # It only runs when *both* jobs in the test stage complete successfully.
38  environment: production
39  script:
40    - echo "Deploying application..."
41    - echo "Application successfully deployed."