Top Banner
Introduction to GitLab Basics and Continuous Integration Christian Stankowic www.stankowic-development.net Free and Open Source software Conference 20.08.2016
43

Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab?...

Oct 05, 2018

Download

Documents

phamdan
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Introduction toGitLabBasics and Continuous Integration

Christian Stankowicwww.stankowic-development.net

Free and Open Source softwareConference20.08.2016

Page 2: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

whoami

Christian Stankowic

Messer Information Services GmbH

Linux & vSphere administrator

Blogger & book author

2

Page 3: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

AGENDA

Page 4: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Agenda

Motivation

Installation

Crash course

Continuous Integration

4

Page 5: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

MOTIVATION

Page 6: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

WhyGit?

simple, distributed version control system

suitable even for non-developers

high security against code corruption byhashing

secure data transfers using SSH

6

Page 7: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Hello Git world!

1 $ git clone http://server/repo.git

2 $ cd repo ; vi myfile.c

3 $ git add *

4 $ git commit -m ’added feature’

5 $ git push

Listing 1: Clone repo and upload changes

7

Page 8: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Git variety

Standalone, local data

Web interface using GitWeb

Hosted (extern and on-premise):GitHubBitBucketGitLabetc...

8

Page 9: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

What is GitLab?

web-based interface for version control withgit

includes additional management anddocumentation functionality

free and paid models available

monthly release cycle

9

Page 10: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Features

Intuitive responsive web interface

file manager

integrated ’ticket tool’ and wiki

automatic code compilation (CI)

and much more...

10

Page 11: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

11

Page 12: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Edition comparison

Feature CE EEfile manager, issues, wiki ✓ ✓Online code changes ✓ ✓GitHub import ✓ ✓LDAP/AD authentication ✓ ✓CI and Docker support ✓ ✓Support × ✓Kerberos authentication × ✓Merge Request Approvals × ✓Issues/Merge Requests templates × ✓

Detailed comparison: about.gitlab.com/features12

Page 13: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Git clients

git, command line

GitX-dev (macOS)

SourceTree Free (Windows, macOS)

GitG / qGit (Linux)

13

Page 14: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Git jargon variety

Description GitLab GitHubMerge code Merge Request Pull RequestCode snippet Snippet GistProject Project RepositoryTeam/Group Group Organization

Source: about.gitlab.com

14

Page 15: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

INSTALLATION

Page 16: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Installation

GitLab CE and EE can be downloaded asOmnibus package (distro-specific, Chef )

available for:Debian 7 / 8RaspbianUbuntu 12.04 / 14.04 / 16.04Enterprise Linux (RHEL, CentOS, SL) 6 / 7

see also: about.gitlab.com/downloads

16

Page 17: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Requirements

at least 2 Cores

minimum 2 GB RAM

more than 500 users: graded by useramount

see also: doc.gitlab.com/install

17

Page 18: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Preparation

Required services and packages:SSH serverCurlPostfixRuby 2.1

Import software source, install gitlab-cepackage

Configure using: gitlab-ctl reconfigure

18

Page 19: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

CRASH COURSE

Page 20: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Projects, users,...

Source code is located in projects

Users (in groups) have access

Code versions vary between branches (e.g.master, nightly,...)

Changes between branches are transferedusing Merge Requests

20

Page 21: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Users and SSH keys

Users can be part of groups (teams)

Each user profile contains SSH client keys

Code changes are transfered securely usingSSH

21

Page 22: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

The first project

Creating a project

Creating a README, LICENSE

Adding your SSH key

Cloning the project

Changing the code

Uploading changes

22

Page 23: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

23

Page 24: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

24

Page 25: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Issues: bug tracking andmore

Documenting bugs, ideas, supportrequests,...

Grouped by tags (e.g. bug, enhancement,...)

Can be mapped to users and milestones

25

Page 26: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

26

Page 27: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Wiki

Full-featured wiki per project

Format usingMarkdown, RDoc or AsciiDoc

Good way to implement big documentations

Wiki is managed using a dedicated Gitrepository

27

Page 28: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

28

Page 29: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

CONTINUOUSINTEGRATION

Page 30: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

WhyCI?

Automating development sub-steps, e.g.:

Compiling sub-programsCompound the productTesting sub-programs with (test units)

Available since version 8.0

30

Page 31: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Functionality

Code changes are applied

GitLab CI selects systems for automation(Runner)

Runners retrieve code changes

Pre-defined scripts are executed

31

Page 32: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

32

Page 33: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

GitLab runner

Agent for Linux, Windows, macOS and BSDwritten in Go

Supports Bash, Batch and PowerShell

Also available as Docker service

Encrypted communication between CI andRunner

Builds can be seen within the GUI

33

Page 34: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

CI configuration

Configuration using YAML file within theproject (.gitlab-ci.yml)

Defines:Scripts pre/after/during compilationBranches and Runner (e.g. custonRunner formaster)Artefacts

34

Page 35: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Excursus: Executor types

Executor controls code compilation:

Shell - simple, local host/Windows system

Docker - for complex projects withdependencies (e.g. databases)

VirtualBox / Parallels - VMs can be clonedduring life-time

SSH - ‘letzte Wahl‘, remote commands

see also: gitlab.com/gitlab-org/...

35

Page 36: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Artefacts

Selection of files after running a build (e.g.binary files)

Can be downloaded from the GUI

Artefacts can be handed to web hooks(content delivery)

Only using shell and Docker executors!

36

Page 37: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Example: Python plugins

Icinga plugins for Linux and Windows

automatic packaging using pyInstaller forWindows

Result: EXE file containing Pythoninterpreter + script

37

Page 38: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

.gitlab-ci.yml

1 before_script:

2 - hostname

3 build:

4 script:

5 - ”powershell.exe -File

build_binaries.ps1”

6 artifacts:

7 paths:

8 - dist

Listing 2: CI configuration 38

Page 39: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

39

Page 40: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

40

Page 41: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

QUESTIONS?

Page 42: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Links

GitLab website: gitlab.org

Omnibus package downloads

GitLab documentation

GitLab CI documentation

GitLab Runner repository

GitLab CI tutorial on my blog

42

Page 43: Introduction to GitLab – Basics and Continuous … · Introduction to GitLab ... 3 $ git add * 4 $ git commit -m ... GitHub BitBucket GitLab etc... 8. WhatisGitLab? web-basedinterfaceforversioncontrolwith

Thanks for your attention!

http://www.stankowic-development.net

43