Basic CI/CD Pipeline Example
This document provides examples of CI/CD pipeline configurations for automating testing, building, and deploying applications.
.gitlab-ci.yml
stages:
- build
- test
- deploy
build-job:
stage: build
script:
- echo "Compiling the code... ๐ ๏ธ"
- echo "Compile complete. โ
"
unit-test-job:
stage: test
script:
- echo "Running unit tests... This will take about 60 seconds. ๐งช"
- sleep 60
- echo "Code coverage is 90% ๐"
lint-test-job:
stage: test
script:
- echo "Linting code... This will take about 10 seconds. ๐"
- sleep 10
- echo "No lint issues found. ๐งน"
deploy-job:
stage: deploy
script:
- echo "Deploying application... ๐"
- echo "Application successfully deployed. ๐"
- echo "Completed... โ
"Explanation
-
Variables:
IMAGE_NAMEandIMAGE_TAGare defined to specify the Docker image name and tag.
-
Stages:
test: Runs tests to ensure the code is working correctly.build: Builds the Docker image.deploy: Deploys the application to a server.
-
Jobs:
run_tests: Uses Python image, installsmake, and runs tests.build_image: Uses Docker-in-Docker to build and push Docker images.deploy: Uses SSH to connect to the server, remove old containers, and run the new Docker container.
Additional Examples
- Build Job: Compiles the code.
- Unit Test Job: Runs unit tests and checks code coverage.
- Lint Test Job: Checks the code for linting issues.
- Deploy Job: Deploys the application if all tests pass.
Icons and Emojis
- ๐ ๏ธ: Build
- โ : Success
- ๐งช: Testing
- ๐: Coverage
- ๐: Linting
- ๐งน: Cleaning
- ๐: Deployment
- ๐: Celebration
By using these configurations, you can set up a robust CI/CD pipeline that automates the process of testing, building, and deploying your applications.