Automating DevOps with GitLab CI/CD Pipelines
local graph
Automating DevOps with GitLab CI/CD Pipelines
Section titled “Automating DevOps with GitLab CI/CD Pipelines”chapter_01
Section titled “chapter_01”node-book_automating-devops-with-gitlab_chapter-01-understanding-life-before-devops — Understanding Life Before DevOps
chapter_02
Section titled “chapter_02”node-book_automating-devops-with-gitlab_chapter-02-practicing-basic-git-commands — Practicing Basic Git Commands
chapter_03
Section titled “chapter_03”node-book_automating-devops-with-gitlab_chapter-03-understanding-gitlab-components — Understanding GitLab Components
chapter_04
Section titled “chapter_04”node-book_automating-devops-with-gitlab_chapter-04-understanding-gitlabs-ci-cd-pipeline-structure — Understanding GitLab’s CI/CD Pipeline Structure
chapter_05
Section titled “chapter_05”node-book_automating-devops-with-gitlab_chapter-05-installing-and-configuring-gitlab-runners — Installing and Configuring GitLab Runners
chapter_06
Section titled “chapter_06”node-book_automating-devops-with-gitlab_chapter-06-verifying-your-code — Verifying Your Code
chapter_07
Section titled “chapter_07”node-book_automating-devops-with-gitlab_chapter-07-securing-your-code — Securing Your Code
chapter_08
Section titled “chapter_08”node-book_automating-devops-with-gitlab_chapter-08-packaging-and-deploying-code — Packaging and Deploying Code
chapter_09
Section titled “chapter_09”node-book_automating-devops-with-gitlab_chapter-09-enhancing-the-speed-and-maintainability-of-ci-cd-pipelines — Enhancing the Speed and Maintainability of CI/CD Pipelines
chapter_10
Section titled “chapter_10”node-book_automating-devops-with-gitlab_chapter-10-extending-the-reach-of-ci-cd-pipelines — Extending the Reach of CI/CD Pipelines
chapter_11
Section titled “chapter_11”node-book_automating-devops-with-gitlab_chapter-11-end-to-end-example — End-to-End Example
chapter_12
Section titled “chapter_12”node-book_automating-devops-with-gitlab_chapter-12-troubleshooting-and-the-road-ahead-with-gitlab — Troubleshooting and the Road Ahead with GitLab
Preface
Section titled “Preface”Organizations in recent years have recognized the benefits of more collaborative and iterative approaches to software development. The traditional model, where development and operations teams worked in silos, made it difficult for companies to quickly and reliably deliver new features. The adoption of DevOps has addressed these challenges by promoting integration and communication between development and operations. The additional proliferation of tooling and automated workflows have helped improve software quality and stability.
A key element of DevOps is continuous integration and continuous delivery (or deployment) (CI/CD). CI/CD is the practice of regularly integrating developer contributions into a shared repository, and then automatically building, testing, and releasing the application. The goal is to minimize the cycle time required to deploy software updates, as well as reduce human error during the process.
This book presents and teaches GitLab as a unified DevOps platform for managing the stages of the software development life cycle. The content will focus primarily on concepts and examples, without locking you into feature capabilities and UI workflows that will likely change over time. After completing this book, you will be equipped to use GitLab to manage almost any software project, while also learning about the best practices that can be applied across other DevOps workflows and CI/CD tools.
Who this book is for
Section titled “Who this book is for”This book is intended for anyone involved in the software development life cycle with software projects of any size. If that sounds broad, that’s because it is! GitLab has something to offer people in a huge variety of roles. Traditional GitLab users include developers, QA, security testers, performance testers, product owners, project managers, UX designers, technical writers, release engineers, and the broad range of roles that fall under the amorphous terms of “DevOps” and “DevSecOps.” So if you find yourself involved with planning, writing, testing, securing, building, packaging, or deploying software, or managing any of those tasks, and you’re wondering how to automate any of the slow, error-prone tasks that you currently perform manually, this book will almost certainly give you ideas about how to improve your life using GitLab and its automated CI/CD pipelines.
This book assumes no prior knowledge other than some familiarity with one or more of the major stages of the software development life cycle. We expect every reader will be involved with different parts of the life cycle, so will focus on the parts of the book that are most relevant to them. That’s a perfectly good way to approach this book, although we recommend everyone read the four chapters that make up the first section since they explain background concepts and terminology that are required knowledge for all GitLab users.
What this book covers
Section titled “What this book covers”Chapter 1*, Understanding Life Before DevOps,* offersa short review of the major software development life cycle stages, and how they can be problematic when done manually.
Chapter 2*, Practicing Basic Git Commands,* provides an introduction to Git, the powerful version control system that GitLab is built around.
Chapter 3*, Understanding GitLab Components,* presents a survey of the major components of GitLab that every GitLab user needs to be familiar with.
Chapter 4*, Understanding the GitLab CI/CD Pipeline Structure,* explains the purpose and structure of GitLab CI/CD pipelines: how they work, how to configure them, and how to view their results.
Chapter 5*, Installing and Configuring GitLab Runners,* explores the critical support tool that powers GitLab CI/CD pipelines.
Chapter 6*, Verifying Your Code,* presents the GitLab CI/CD pipeline features dedicated to ensuring that your code is of high-quality and functionally correct.
Chapter 7*, Securing Your Code,* discusses the GitLab CI/CD pipeline scanners that identify security vulnerabilities in your code.
Chapter 8*, Packaging and Deploying Your Code,* explains how to use GitLab CI/CD pipelines to automate the usage of common build and package tools to get your code into a deployable form.
Chapter 9*, Enhancing the Speed and Maintainability of CI/CD Pipelines,* surveys some techniques for speeding up GitLab CI/CD pipelines and making them easy to read and maintain.
Chapter 10*, Extending the Reach of CI/CD Pipelines,* explains how to use GitLab CI/CD pipelines to spot performance problems in your code, how to enable or disable product features from the GitLab dashboard, and how to use GitLab to develop mobile applications.
Chapter 11*, End-to-End Example,* demonstrates an end-to-end example that combines many of the GitLab techniques you’ve learned into a single, realistic software development workflow.
Chapter 12*, Troubleshooting and the Road Ahead with GitLab,* provides a collection of tips for troubleshooting problematic GitLab CI/CD pipelines, along with some thoughts on using GitOps to manage your infrastructure and possible future directions for GitLab.
To get the most out of this book
Section titled “To get the most out of this book”You will get the most out of this book if you have an account on a GitLab instance, whether on gitlab.com (that is, a software-as-a-service instance) or on a self-hosted instance. It will also be useful to have access to a Linux, macOS, or Windows terminal with Git installed. Some familiarity with the major stages of the software development life cycle will be helpful as well. No programming knowledge is assumed, but some experience with YML or other structured data formats will make many parts of the book easier to follow.
The code examples in this book were tested with GitLab version 15.x. They should work with future versions as well. All screenshots are also taken from GitLab version 15.x. Future versions are likely to introduce some drift in the GUI, but the fundamental concepts and operations should remain the same.
| Software/hardware covered in the book | Operating system requirements |
|---|---|
| GitLab 15+ | Linux, macOS, or Windows |
| Git | Linux, macOS, or Windows |
Conventions used
Section titled “Conventions used”There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system.”
A block of code is set as follows:
employee_name = get_user_input()sql = "SELECT salary FROM employee_records WHERE employee_name = $employee_name" ENTERcall_database(sql)When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
deploy-to-staging:stage: stagingscript: ./deploy-staging.shtags:- windows- stagingAny command-line input or output is written as follows:
$ git --versiongit version 2.25.1Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Select System info from the Administration panel.”
Tips or important notes
Appear like this.