Gitlab CI Course Notes - Read the Docs
Gitlab CI Course Notes
Release March 2020
Apr 17, 2020
Contents:
1 About
1
2 Introduction
3
2.1 Your first pipeline in Gitlab CI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Gitlab architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Why Gitlab / Gitlab CI? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4 How much does Gitlab cost? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Basic CI/CD workflow with Gitlab CI
7
3.1 What is CI / CD? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Short introduction to Node.js and npm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3 Creating a new project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.4 Building the project locally . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.5 Short introduction to images and Docker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.6 Building the project using Gitlab CI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.7 Adding a test stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.8 Running jobs in parallel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.9 Running jobs in the background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.10 Deployment using surge.sh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.11 Using environment variables for managing secrets . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.12 Deploying the project using Gitlab CI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.13 How does Surge use environment variables? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4 Gitlab CI Fundamentals
15
4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2 Predefined environment variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.3 Pipeline triggers / Retrying failed jobs / Pipeline schedules . . . . . . . . . . . . . . . . . . . . . . . 16
4.4 Using caches to optimize the build speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.5 Cache vs Artifacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.6 Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.7 Defining variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.8 Manual deployments / Manually triggering jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.9 Merge Requests: Using Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.10 Merge requests: Configuring Gitlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.11 Merge requests: Your first merge request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.12 Dynamic environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.13 Destroying environments (Clean-up after the Merge Request) . . . . . . . . . . . . . . . . . . . . . 22
i
5 YAML Basics
23
5.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.2 Understanding YAML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.3 Using anchors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6 Using Gitlab CI to build and deploy a Java application to AWS Elastic Beanstalk
25
6.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.2 Introduction to the Java application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.3 Running the application in Postman . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.4 Continuous Integration (CI) pipeline overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.5 Smoke test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.6 CI/CD pipeline recap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.7 Brief introduction to Amazon Web Services (AWS) . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.8 Serverless computing with AWS Elastic Beanstalk . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.9 Manually deploying a Java application to AWS Elastic Beanstalk . . . . . . . . . . . . . . . . . . . 29
6.10 How to deploy to AWS from GitLab CI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.11 Getting started with AWS S3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.12 GitLab Group settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.13 How to upload a file to AWS S3 from GitLab CI . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6.14 How to deploy a Java application to AWS Elastic Beanstalk using the AWS CLI . . . . . . . . . . . 30
6.15 Create an application version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6.16 Verify the application version after deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6.17 Ensuring coding standards with tools for codestyle checking . . . . . . . . . . . . . . . . . . . . . . 31
6.18 Introduction to unit testing in CI pipelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.19 Unit test stage: Run JUnit tests with GitLab CI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.20 How to structure a CI/CD pipeline in GitLab CI? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.21 API test stage: Run Postman API tests in GitLab CI . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.22 GitLab Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
7 Gitlab CI Online course
33
8 Indices and tables
35
ii
1 CHAPTER
About
I have created these course notes for the students of the "Gitlab CI: Pipelines, CI/CD and DevOps for Beginners" online course on Udemy. If you are not a student yet, consider registering so that you can take full advantages of this material. It is additional material for the students that prefer to take notes. You can easily print the entire course content and add your notes. I did my best to put this together, but it is not perfect. If you spot any spelling mistakes or would like to contribute and make this better, feel free to send me a Pull Request on Enjoy! - Valentin
1
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- git cheat sheet programming with mosh
- gitlab ci course notes read the docs
- node tutorialspoint
- developing acrobat applications using javascript
- jquery tutorialspoint
- you don t know js up going xiaoguo
- the complete beginner s guide to react html5 hive
- javascript tutorial
- aws lambda developer guide
- javascript absolute beginner s guide