Gitlab
Gitlab
Gitlab
#gitlab
Table of Contents
About 1
Remarks 2
Versions 2
Examples 3
Installation or Setup 3
Examples 5
Introduction 6
Remarks 6
Examples 6
Runner installation 6
Windows 7
Runner configuration 7
Examples 10
Credits 11
About
You can share this PDF with anyone you feel could benefit from it, downloaded the latest version
from: gitlab
It is an unofficial and free gitlab ebook created for educational purposes. All the content is
extracted from Stack Overflow Documentation, which is written by many hardworking individuals at
Stack Overflow. It is neither affiliated with Stack Overflow nor official gitlab.
The content is released under Creative Commons BY-SA, and the list of contributors to each
chapter are provided in the credits section at the end of this book. Images may be copyright of
their respective owners unless otherwise specified. All trademarks and registered trademarks are
the property of their respective company owners.
Use the content presented in this book at your own risk; it is not guaranteed to be correct nor
accurate, please send your feedback and corrections to info@zzzprojects.com
https://riptutorial.com/ 1
Chapter 1: Getting started with gitlab
Remarks
GitLab is a web-based version control software based on git and adds additional features such as
branch management bug tracking and continuous integration. It is developed in Ruby.
GitLab Community Edition (CE) is being developed open-source and uses the MIT-License. Since
August 2013 GitLab Inc. is providing the enterprise-grade Enterprise Edition (EE) which includes
more features than the Community Edition.
GitLab.com is the Software as a Service alternative and runs itself on a Enterprise Edition. It is
free of charge and supports private and public repositories.
Versions
8.15 2016-12-22
8.14 2016-11-22
8.13 2016-10-22
8.12 2016-09-22
8.11 2016-08-22
8.10 2016-07-22
8.9 2016-06-22
8.8 2016-05-22
8.7 2016-04-22
8.6 2016-03-22
8.5 2016-02-22
8.4 2016-01-22
8.3 2015-12-22
8.2 2015-11-22
8.1 2015-10-22
https://riptutorial.com/ 2
Version Release Date
8.0 2015-09-22
Examples
Installation or Setup
This is a short summary of the GitLab guide on Install a GitLab CE Omnibus package.
Requirements
In order to install the GitLab Community Edition on your server, you should read the requirements
page. To make it brief, the recommended requirements are:
Installation
The recommended method is to install the Omnibus package, which is fast to install. It contains
GitLab and all its dependencies (Ruby, PostgreSQL, Redis, Nginx, Unicorn, etc.). For other
methods check out the GitLab's installation options
With Ubuntu 16.04 as the recommended OS, this guide describes the installation steps on Debian
based distributions. For CentOS, RHEL, Oracle Linux and Scientific Linux, please refer to the
original guides:
Install necessary dependencies. If you use Postfix select 'Internet Site' during setup
If you do not want to install the repository through a piped script, download the package manually
https://riptutorial.com/ 3
and install it using
dpkg -i gitlab-ce_<version>.deb
Finally browse to the hostname and login. At first you will be redirected to provide a password for
the initial administrator account. After that you're able to login in. The default administrator
account username is root.
https://riptutorial.com/ 4
Chapter 2: Android CI Configuration
Examples
Build Tools 24.0.0 - Android
image: jangrewe/gitlab-ci-android
before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 openjdk-8-jdk
- echo y | ${ANDROID_HOME}/tools/android --silent update sdk --no-ui --all --filter android-
24
- echo y | ${ANDROID_HOME}/tools/android --silent update sdk --no-ui --all --filter
platform-tools
- echo y | ${ANDROID_HOME}/tools/android --silent update sdk --no-ui --all --filter build-
tools-24.0.0
- echo y | ${ANDROID_HOME}/tools/android --silent update sdk --no-ui --all --filter extra-
android-m2repository
- echo y | ${ANDROID_HOME}/tools/android --silent update sdk --no-ui --all --filter extra-
google-google_play_services
- echo y | ${ANDROID_HOME}/tools/android --silent update sdk --no-ui --all --filter extra-
google-m2repository
- chmod +x gradlew
build:
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/apk/app-debug.apk
Change the build tools number to your compile target, and fork the docker image if you don't want
to install everything every time.
https://riptutorial.com/ 5
Chapter 3: Continuous integration
Introduction
The GitLab CI runs build jobs based on a checked in .gitlab-ci.yml. Jobs are run on a remote
server in it's own docker container.
Remarks
• A build will fail if any lines in a job return an exit code != 0.
Examples
Runner installation
Debian/Ubuntu
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-
runner/script.deb.sh | sudo bash
CentOS
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-
runner/script.rpm.sh | sudo bash
Debian/Ubuntu
CentOS
https://riptutorial.com/ 6
• Enter the URL to your GitLab CI. It should look like this http://example.com/ci
• Enter the registration token. If this is a project specfic runner you can find the token in
Project settings -> Runners. If it is a shared runner go to Admin area -> Runners and find the
registration token there.
• Select the executor which you want to use. Valid executors are: shell (These can be later
configured to use sh or bash),docker,docker-ssh,ssh,parallels,virtualbox,docker+machine or
docker-ssh+machine. For more detail information on executors check the official
documentation.
Windows
1. Download the runner binary and place it somewhere appropriate on your system.
2. Open a command prompt as Administrator
3. Register the runner
<runner-binary> register
• Enter the URL to your GitLab CI. It should look like this http://example.com/ci
• Enter the registration token. If this is a project specfic runner you can find the token in
Project settings -> Runners. If it is a shared runner go to Admin area -> Runners and find the
registration token there.
• Select the executor which you want to use. Valid executors are: shell(Can be later
configured to use cmd or powershell),ssh,parallels or virtualbox. For more detail information
on executors check the official documentation.
<runner-binary> start
Runner configuration
Debian/Ubuntu/CentOS
/etc/gitlab-runner/config.toml
https://riptutorial.com/ 7
if run as root
Windows
concurrent = 1
[[runners]]
name = "ExampleRunner"
url = "https://example.com/ci"
token = "f3058595ca4b2d217726466b1feed9"
executor = "shell"
shell = "bash"
Some projects like GoLang might need to clone other dependent GitLab repositories during build.
To get this working you can add a Deploy Key to dependent repositories and put the private key
(without password) into the origin repository.
Create and check-in a SSH key inside the Git Repository that depends on some other repository
during build time:
# In the following promt name the key "deploykey" and leave the passphrase empty
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): deploykey
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in deploykey.
Your public key has been saved in deploykey.pub.
Use the deploykey.pub to configure a deploykey in the dependent repository. You can find an
Deploykey page in the GitLab Project Settings.
before_script:
# Git and SSH setup to clone private repos
# Needs the deploykey file to be installed in all dependent repositories
- git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com/"
# Add gitlab to known_hosts
https://riptutorial.com/ 8
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
- ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
# Start the ssh agent and add the deploykey
- chmod 400 deploykey
- eval $(ssh-agent -s)
- ssh-add deploykey
Now any call to git clone inside your build should work. Even if it's via some other tools like go get,
govendor sync, or whatever you are using.
https://riptutorial.com/ 9
Chapter 4: Google Cloud SDK CI
Configuration
Examples
Open JDK 8 Docker Example
image: openjdk:8-jdk
before_script:
- curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-
cloud-sdk.tar.gz
- mkdir -p /usr/local/gcloud
- tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz
- echo y |/usr/local/gcloud/google-cloud-sdk/install.sh
- chmod +x ./gradlew
build:
script:
- ./gradlew build
artifacts:
paths:
- app/build/outputs/
https://riptutorial.com/ 10
Credits
S.
Chapters Contributors
No
Getting started with Alessandro Trinca Tornidor, Community, Connor Shea, Fairy,
1
gitlab Greg Dubicki, jim
Android CI
2 ReverseCold
Configuration
Continuous
3 Fairy, Tarion
integration
https://riptutorial.com/ 11