Over a million developers have joined DZone.

Continuous Integration and Continuous Deployment With GitLabCI

DZone 's Guide to

Continuous Integration and Continuous Deployment With GitLabCI

In just seven steps and with some software installed, you can easily create a continuous integration/continuous deployment pipeline using GitLab CI.

· DevOps Zone ·
Free Resource

Continuous integration and continuous deployment have become significant parts of the software development process. GitLab comes with built-in continuous integration, continuous deployment, and continuous delivery support to build, test, and deploy your application.

This article walks through the steps needed to create a CI/CD pipeline using GitLab CI. We are showing here how to build and deploy Angular code (front-end).


  • You have a GitLab account and have created a GitLab repository for storing source code.

  • You have a server machine with Gitlab Runner, Maven, Ansible, Docker, and Nexus installed.


1. Register and Install Gitlab-runner

Do this step using this link: https://docs.gitlab.com/runner/install/. Note: Use the shell executor while registering Runner.

2. Add Config File to Your Project Repository

Add your source code to the repository. Add a .gitlab-ci.yml file to the root directory of your project .  Open the file and add the contents. Here, we have written build and deploy code in same stage:

.gitlab-ci.yml3. Add Variables 

Replace variables with values in the 'Variables' section under the 'Settings' tab.

Image title

4. Setup Nexus Repository

Note: Below are the settings for the current project scenario.

Nexus artifactory

5. Ansible Playbook 

Below is an Ansible playbook for the current project scenario.

Image title

6. Repository View

Now, after adding source code and config files, the repository will look as below:

Image title

7. CI/CD Pipeline Execution

Any changes to code will trigger the pipeline and we can see the status in CI/CD Pipeline tab.

Image title

You can see the complete log status if you click the 'failed' or 'passed' status icons.

Image title


Developers can start using this CI/CD pipeline to build and deploy by updating their code in the repository. Artifacts will be available in Nexus repository for further deployments if there are any. You can set up more jobs for enhancing the pipeline. This basic CI/CD pipeline using GitLab CI would look as below:

Image title

devops ,tutorial ,gitlab ci ,continuous integration ,continuous deployment

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}