|
|
## DevOps Practical
|
|
|
|
|
|
### Introduction to DevOps
|
|
|
|
|
|
DevOps is a set of practices that companies/startups follow for writing software.
|
|
|
- The practice is to build, test and deploy each change in the software as soon as the changes are submitted.
|
|
|
- It increases speed of software development and make sure that the software quality is high.
|
|
|
|
|
|
### DevOps stages
|
|
|
|
|
|
Devops has these stages
|
|
|
|
|
|
1. Plan
|
|
|
2. Code
|
|
|
3. Build
|
|
|
4. Test
|
|
|
5. Release
|
|
|
6. Deploy
|
|
|
|
|
|
|
|
|
### Steps to run DevOps using gitlab
|
|
|
|
|
|
Gitlab provides ready-to-use templates to run DevOps on sample programs.
|
|
|
|
|
|
For Example:
|
|
|
|
|
|
We will use a simple CPP program which `adds` and `substracts` 2 numbers.
|
|
|
|
|
|
1. Fork the repository.
|
|
|
![fork](upload/Selection_023.png)
|
|
|
- Select your username in the next window.
|
|
|
|
|
|
2. Clone the repository.
|
|
|
- Copy Repository URL from the
|
|
|
|
|
|
![clone](upload/Selection_024.png)
|
|
|
|
|
|
- Open VSCode, Go to File --> Open Folder (open any empty folder)
|
|
|
- Press `Ctrl` + `J`
|
|
|
- Type `git clone {your-repository URL here}`
|
|
|
|
|
|
![clone2](upload/Selection_025.png)
|
|
|
|
|
|
3. Make changes to the code.
|
|
|
- Add another line printing addition of 100 + 80.
|
|
|
![change-code](upload/Selection_026.png)
|
|
|
|
|
|
|
|
|
4. Submit the changes.
|
|
|
- Press `Ctrl` + `J`
|
|
|
- Run commands
|
|
|
|
|
|
```sh
|
|
|
cd devops-trial
|
|
|
git config --global user.name "{Your-name}"
|
|
|
git config --global user.email "{your-email-id}"
|
|
|
git add .
|
|
|
git commit -m "Added add 10 + 80"
|
|
|
git push
|
|
|
```
|
|
|
![submit-cmd](upload/Selection_027.png)
|
|
|
|
|
|
5. See your code Build, Test and Deploy.
|
|
|
- Go to your repository, CI/CD --> Pipelines.
|
|
|
![pipleines](upload/Screenshot%20from%202020-11-03%2015-34-57.png)
|
|
|
- You can see Build, Test and Deploy devOps stages passing.
|
|
|
![stages](upload/Selection_028.png)
|
|
|
- Click on the `passed` to see all the individual stage summary.
|
|
|
![stages-1](upload/Selection_029.png)
|
|
|
|
|
|
6. Thats is it done, you have successfully seen your code Build, Test and Deployed.
|
|
|
|