GitLab Quick Start Guide
eBook - ePub

GitLab Quick Start Guide

Migrate to GitLab for all your repository management solutions

  1. 180 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

GitLab Quick Start Guide

Migrate to GitLab for all your repository management solutions

About this book

Port projects over from GitHub and convert SVN projects to GitLab hosted git projects

Key Features

  • Effective guide for GitLab migration from GitHub and SVN
  • Learn to implement DevOps with GitLab 11
  • Manage projects with issue boards and time tracking

Book Description

Gitlab is an open source repository management and version control toolkit with an enterprise offering. This book is the ideal guide to GitLab as a version control system (VCS), issue management tool, and a continuous integration platform.

The book starts with an introduction to GitLab, a walkthrough of its features, and explores concepts such as version control systems, continuous integration, and continuous deployment. It then takes you through the process of downloading and installing a local copy of the on-premise version of GitLab in Ubuntu and/or CentOS.

You will look at some common workflows associated with GitLab workflow and learn about project management in GitLab. You will see tools and techniques for migrating your code base from various version control systems such as GitHub and SVN to GitLab.

By the end of the book, you will be using Gitlab for repository management, and be able to migrate projects from other VCSs to GitLab.

What you will learn

  • Set up CI and test builds for your projects
  • Understand the benefits and limitations of GitLab workflow
  • Migrate from other common VCS platforms to Gitlab
  • Create, review, and merge code changes
  • Learn to branch local code and create a new branch in GitLab
  • Configure sequential stages and simultaneous stages for CI/CD
  • Access Mattermost for on-premise GitLab
  • Discover the issue tracking features of GitLab

Who this book is for

The book is intended for the developers, SREs, and DevOps professionals who are looking for techniques to port their codebase to GitLab from GitHub or are looking to work with GitLab as their version control system of choice. If you've used other VCSs before, that will help with this book.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Continuous Integration and Continuous Deployment

Continuous integration and continuous deployment, commonly known as CI/CD, is a computing and IT philosophy whereby code is continuously tested and deployed/released automatically with as little manual handling as possible. This requires extra tools, usually a specialized platform that handles testing newly committed code as well as other tools that can take that code and package it for release, or upload it to a new version of the platform of website. However, if you're using GitLab, you have all the tools you need to get up and running and practicing CI/CD in no time.
In this chapter, we'll cover the following topics:
  • How to install GitLab Runner
  • Setting up tests in our GitLab example project
  • The .gitlab-ci.yml file
  • Setting up a .gitlab-ci.yml file in our GitLab example project
  • Breaking down advanced .gitlab-ci.yml files
  • The CI/CD interface in GitLab
By the end of this chapter, you'll have a good idea of how to navigate GitLab's CI/CD features and be ready to start integrating it into your own project.

How to install GitLab Runner

GitLab's implementation of a continuous integration and continuous deployment platform works off the idea of Runners, which are programs that are installed on other servers and can connect to the GitLab instance to receive jobs to run. These jobs can involve building, testing, and deploying code. In this section, we'll explore how to install GitLab Runner on Ubuntu, CentOS, and manually via binaries.

Ubuntu

To easily install GitLab Runner on Ubuntu, make sure that you have a recent version installed, as GitLab only provides packages for the currently supported versions. Next, open a Terminal session on your Ubuntu box and run the following command:
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
cat > /etc/apt/preferences.d/pin-gitlab-runner.pref <<EOF
Explanation: Prefer GitLab provided packages over the Debian native ones
Package: gitlab-runner
Pin: origin packages.gitlab.com
Pin-Priority: 1001
EOF
sudo apt-get install gitlab-runner
Let's break this down a bit.
The first command downloads and executes a script from GitLab that checks if your operating system is compatible, sets up your local package manager (apt) with the right URLs to get packages and lists from, and then updates those lists. This is a security anti-pattern, though, as the user isn't sure what they're executing and it could contain malicious code. I'd recommend downloading the script to your machine and then executing it yourself after having a read of the code so that you know what it will do.
The next section pins the package to the GitLab origin. This is necessary because Ubuntu introduced a GitLab Runner package as well. However, it can be a lot more out of date than the GitLab version and so it's recommended to pin it to the GitLab download origin.
Lastly, we install the package so that it's ready to go.
Now, we need to register the Runner. To do that, go to the How to register Runners section in this chapter.

CentOS

To easily install GitLab Runner on Ubuntu, make sure that you have a recent version installed, as GitLab only provides packages for the currently supported versions. Next, open a terminal session on your Ubuntu box and run the following command:
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
sudo yum install gitlab-runner
Let's break this down a bit.
The first command downloads and executes a script from GitLab that checks if your operating system is compatible, sets up your local package manager (yum) with the right URLs to get packages and lists from, and then updates those lists. This is a security anti-pattern, though, as the user isn't sure what they're executing and it could contain malicious code. I'd recommend downloading the script to your machine and then executing it yourself after having a read of the code so that you know what it will do.
Lastly, we install the package so that it's ready to go.
Now, we need to register the Runner. To do that, go to the How to register Runners section in this chapter.

Binaries

If you don't want to use the DEB or RPM packages to install GitLab Runner, or are using an operating system without those package managers available, you can still install GitLab Runner manually using the binary downloads.
Run the following commands to download the Runner, give it permissions to execute, create a user for it, and then install and run it:
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
sudo chmod +x /usr/local/bin/gitlab-runner
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start
If you're using an ARM platform such as a Raspberry Pi or other lightweight device, you can change the amd64 to arm in the download link.

How to register Runners

Once you have your Runner client installed, you can go through the process of registering it. There are two ways of doing this: in the administrator panel (only in self-hosted GitLab) or in project settings. The former creates a global shared Runner that can be assigned to multiple different projects or even made available to any project on the instance that needs a Runner. The latter method creates Runners that are tied specifically to a particular project/repository. There are also group runners, which can be assigned to a group of projects, but they are beyond the scope of this book.

Admin panel

To do this, you first need to log in to your GitLab instance as an account with administrator permissions. Once you're logged in, you need to click the spanner/wrench icon up the top at the end of the left-hand side menu. From here, go to Overview | Runners to be greeted by a scene like the following:
...

Table of contents

  1. Title page
  2. Copyright and Credits
  3. Dedication
  4. About Packt
  5. Contributors
  6. Preface
  7. Introducing GitLab
  8. Setting Up GitLab
  9. GitLab Flow
  10. Issues to Merge Requests
  11. Continuous Integration and Continuous Deployment
  12. Porting from GitHub or Subversion (SVN)
  13. Advanced and Paid Features
  14. Introduction To Markdown
  15. Other Books You May Enjoy

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access GitLab Quick Start Guide by Adam O'Grady in PDF and/or ePUB format, as well as other popular books in Computer Science & Computer Science General. We have over one million books available in our catalogue for you to explore.