CI/CD Pipeline with GitLab

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.

gl

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.

gl2

Click on create project!

Your version control is setup now with your project and should look like below

gl3.PNG

Step 3) Setup and Configure CI/CD with your project by adding gitlab-ci.yml file

gl0

Commit the changes to add the gitlab-ci.yml file

gl00

Step 4) Let us create a separate branch and do some commits!

Open Web IDE:

gl4

Make some changes in the code.

I added “Let us make a difference!” in the existing return string a shown below:

gl5.PNG

Also make changes JUnit test file so that test cases can pass!

gl6.PNG

 

Let us commit the changes in the new branch!

gl7.PNG

 

Select “Create a new branch and merge request” and update the commit message.

gl8

To proceed, click on Stage & Commit

gl9.PNG

Approve the merge request

gl19gl11

With CI/CD confured, it will autorun the CI/C pipeline – Build, test jobs and deploy

gl20.PNG

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

gl21.PNG

All the jobs in the pipeline are passed!

g22

Check the status(running, passed or failed) in the Jobs tab under CI/CD.

g24

You can configure environments which will Auto deploy your app.

g23

So this was it!

Happy pipelining!

If you have any queries, post your comments below!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s