Skip to main content

Experiment No. 3 Title: Implement GitLab Operations using Git.

 Experiment No. 3

Title: Implement GitLab Operations using Git.


Objective:

The objective of this experiment is to guide you through the process of using Git commands to interact with GitLab, from creating a repository to collaborating with others through merge requests.



Introduction:

GitLab is a web-based platform that offers a complete DevOps lifecycle toolset, including version control, continuous integration/continuous deployment (CI/CD), project management, code review, and collaboration features. It provides a centralized place for software development teams to work together efficiently and manage the entire development process in a single platform.


Key Features of GitLab:


  • Version Control: GitLab provides version control capabilities using Git, allowing developers to track changes to source code over time. This enables collaboration, change tracking, and code history maintenance.

  • Repositories: Repositories on GitLab are collections of files, code, documentation, and assets related to a project. Each repository can have multiple branches and tags, allowing developers to work on different features simultaneously.

  • Continuous Integration/Continuous Deployment (CI/CD): GitLab offers robust CI/CD capabilities. It automates the building, testing, and deployment of code changes, ensuring that software is delivered rapidly and reliably.

  • Merge Requests: Merge requests in GitLab are similar to pull requests in other platforms. They enable developers to propose code changes, collaborate, and get code reviewed before merging it into the main codebase.

  • Issues and Project Management: GitLab includes tools for managing project tasks, bugs, and enhancements. Issues can be assigned, labeled, and tracked, while project boards help visualize and manage work.

  • Container Registry: GitLab includes a container registry that allows users to store and manage Docker images for applications.

  • Code Review and Collaboration: Built-in code review tools facilitate collaboration among team members. Inline comments, code discussions, and code snippets are integral parts of this process.

  • Wiki and Documentation: GitLab provides a space for creating project wikis and documentation, ensuring that project information is easily accessible and well-documented.

  • Security and Compliance: GitLab offers security scanning, code analysis, and compliance features to help identify and address security vulnerabilities and ensure code meets compliance standards.

  • GitLab Pages: Similar to GitHub Pages, GitLab Pages lets users publish static websites directly from a GitLab repository.


Benefits of Using GitLab:


  • End-to-End DevOps: GitLab offers an integrated platform for the entire software development and delivery process, from code writing to deployment.

  • Simplicity: GitLab provides a unified interface for version control, CI/CD, and project management, reducing the need to use multiple tools.

  • Customizability: GitLab can be self-hosted on-premises or used through GitLab's cloud service. This flexibility allows organizations to choose the hosting option that best suits their needs.

  • Security: GitLab places a strong emphasis on security, with features like role-based access control (RBAC), security scanning, and compliance checks.

  • Open Source and Enterprise Versions: GitLab offers both a free, open-source Community Edition and a paid, feature-rich Enterprise Edition, making it suitable for individual developers and large enterprises alike.



Materials:

  • Computer with Git installed (https://git-scm.com/downloads)

  • GitLab account (https://gitlab.com/)

  • Internet connection


Experiment Steps:


Step 1: Creating a Repository

  • Sign in to your GitLab account.

  • Click the "New" button to create a new project.

  • Choose a project name, visibility level (public, private), and other settings.

  • Click "Create project."


Step 2: Cloning a Repository

  • Open your terminal or command prompt.

  • Navigate to the directory where you want to clone the repository.

  • Copy the repository URL from GitLab.

  • Run the following command:


git clone <repository_url>

  • Replace <repository_url> with the URL you copied from GitLab.

  • This will clone the repository to your local machine.


Step 3: Making Changes and Creating a Branch

  • Navigate into the cloned repository:

cd <repository_name>


  • Create a new text file named "example.txt" using a text editor.

  • Add some content to the "example.txt" file.

  • Save the file and return to the command line.

  • Check the status of the repository:

git status

  • Stage the changes for commit:

git add example.txt


  • Commit the changes with a descriptive message:

git commit -m "Add content to example.txt"


  • Create a new branch named "feature":

git branch feature


  • Switch to the "feature" branch:

git checkout feature


Step 4: Pushing Changes to GitLab

  • Add Repository URL in a variable 

git remote add origin  <repository_url>

  • Replace <repository_url> with the URL you copied from GitLab.


  • Push the "feature" branch to GitLab:

git push origin feature

  • Check your GitLab repository to confirm that the new branch "feature" is available.


Step 5: Collaborating through Merge Requests

  1. Create a merge request on GitLab:

    • Go to the repository on GitLab.

    • Click on "Merge Requests" and then "New Merge Request."

    • Choose the source branch ("feature") and the target branch ("main" or "master").

    • Review the changes and click "Submit merge request."

  2. Review and merge the merge request:

    • Add a title and description for the merge request.

    • Assign reviewers if needed.

    • Once the merge request is approved, merge it into the target branch.


Step 6: Syncing Changes

  • After the merge request is merged, update your local repository:

git checkout main

git pull origin main


Conclusion:

This experiment provided you with practical experience in performing GitLab operations using Git commands. You learned how to create repositories, clone them to your local machine, make changes, create branches, push changes to GitLab, collaborate through merge requests, and synchronise changes with remote repositories. These skills are crucial for effective collaboration and version control in software development projects using GitLab and Git.


Questions/Exercises: 

  1. What is GitLab, and how does it differ from other version control platforms?

  2. Explain the significance of a GitLab repository. What can a repository contain?

  3. What is a merge request in GitLab? How does it facilitate the code review process?

  4. Describe the steps involved in creating and submitting a merge request on GitLab.

  5. What are GitLab issues, and how are they used in project management?

  6. Explain the concept of a GitLab project board and its purpose in organising tasks.

  7. How does GitLab address security concerns in software development? Mention some security-related features.

  8. Describe the role of compliance checks in GitLab and how they contribute to maintaining software quality.


Comments

Popular posts from this blog

Experiment No. 5 Title: Applying CI/CD Principles to Web Development Using Jenkins, Git, and Local HTTP Server

  Experiment No. 5 Title: Applying CI/CD Principles to Web Development Using Jenkins, Git, and Local HTTP Server  Objective: The objective of this experiment is to set up a CI/CD pipeline for a web development project using Jenkins, Git, and webhooks, without the need for a Jenkinsfile. You will learn how to automatically build and deploy a web application to a local HTTP server whenever changes are pushed to the Git repository, using Jenkins' "Execute Shell" build step. Introduction: Continuous Integration and Continuous Deployment (CI/CD) is a critical practice in modern software development, allowing teams to automate the building, testing, and deployment of applications. This process ensures that software updates are consistently and reliably delivered to end-users, leading to improved development efficiency and product quality. In this context, this introduction sets the stage for an exploration of how to apply CI/CD principles specifically to web development using J

Experiment No. 6 Title: Exploring Containerization and Application Deployment with Docker

  Experiment No. 6 Title: Exploring Containerization and Application Deployment with Docker  Objective: The objective of this experiment is to provide hands-on experience with Docker containerization and application deployment by deploying an Apache web server in a Docker container. By the end of this experiment, you will understand the basics of Docker, how to create Docker containers, and how to deploy a simple web server application. Introduction Containerization is a technology that has revolutionised the way applications are developed, deployed, and managed in the modern IT landscape. It provides a standardised and efficient way to package, distribute, and run software applications and their dependencies in isolated environments called containers. Containerization technology has gained immense popularity, with Docker being one of the most well-known containerization platforms. This introduction explores the fundamental concepts of containerization, its benefits, and how it differs

Experiment No. 10 Title: Create the GitHub Account to demonstrate CI/CD pipeline using Cloud Platform.

  Experiment No. 10 Title: Create the GitHub Account to demonstrate CI/CD pipeline using Cloud Platform. Objective: The objective of this experiment is to help you create a GitHub account and set up a basic CI/CD pipeline on GCP. You will learn how to connect your GitHub repository to GCP, configure CI/CD using Cloud Build, and automatically deploy web pages to an Apache web server when code is pushed to your repository. Introduction: Continuous Integration and Continuous Deployment (CI/CD) pipelines are essential for automating the deployment of web applications. In this experiment, we will guide you through creating a GitHub account and setting up a basic CI/CD pipeline using Google Cloud Platform (GCP) to copy web pages for an Apache HTTP web application. Continuous Integration and Continuous Deployment (CI/CD) is a crucial practice in modern software development. It involves automating the processes of code integration, testing, and deployment to ensure that software changes are co