With Auto DevOps in GitLab, It will automatically build, test, and deploy your application based on a predefined CI/CD configuration.
To create a CI/CD pipeline here are pre requisites:
- GitLab account
- Git and Source code management basic knowledge
- Google cloud account for Kubernetes cluster
Step-1) Create a project from a template in GitLab or you can also import your project from other sources like GitHub, Zip file etc.
Let us choose a spring project!
Click on Use template.
Step 2) Fill all the details like project name, description etc
It will be private repo.
Click on create project!
Your version control is setup now with your project and should look like below
Step 3) Setup and Configure CI/CD with your project by adding gitlab-ci.yml file
Commit the changes to add the gitlab-ci.yml file
Step 4) Let us create a separate branch and do some commits!
Open Web IDE:
Make some changes in the code.
I added “Let us make a difference!” in the existing return string a shown below:
Also make changes JUnit test file so that test cases can pass!
Let us commit the changes in the new branch!
Select “Create a new branch and merge request” and update the commit message.
To proceed, click on Stage & Commit
Approve the merge request
With CI/CD confured, it will autorun the CI/C pipeline – Build, test jobs and deploy
Click on each jobs like build, test jobs like code quality, container scanning..etc as shown above to see the test running in the pipeline:
It runs the builds on Docker
All the jobs in the pipeline are passed!
Check the status(running, passed or failed) in the Jobs tab under CI/CD.
You can configure environments which will Auto deploy your app.
So this was it!
If you have any queries, post your comments below!