GitLab Tutorial

GitLab CI – Container Registry

GitLab CI &-8211; Container Registry &-8211; this Article or News was published on this date:2019-05-15 07:44:04 kindly share it with friends if you find it helpful

GitLab CI &-8211; Container Registry


Advertisements


Description

Container registry is a storage and content delivery system, which stores their Docker (it is database of predefined images used to run applications.) images.

Deploying the Registry

You can deploy the registry by using the below commands −

Step 1 − First, login to your GitLab server using SSH (Secure Shell).

Step 2 − Now start the registry container by using below command −

$ docker run -d -p 5000:5000 --restart = always --name registry registry:2

GitLab Container Registry

The -p 5000:5000 specifies first part as host port and second part as port within the container. The &-8211;restart = always flag restarts the registry automatically when Docker restarts. The registry:2 is defined as an image.

Step 3 − Now, pull the image from Docker hub to your registry −

$ docker pull ubuntu:16.04

GitLab Container Registry

The above command pulls the ubuntu:16.04 image from Docker Hub.

Step 4 − Next, tag the image to point your registry −

$ docker tag ubuntu:16.04 localhost:5000/my-ubuntu

Here, we are tagging the localhost:5000/my-ubuntu image for an existing ubuntu:16.04 image.

Step 5 − Push the image to local registry which is executing at localhost:5000.

$ docker push localhost:5000/my-ubuntu

GitLab Container Registry

Step 6 − Now remove the cached (ubuntu:16.04 and localhost:5000/my-ubuntu) images from the registry −

$ docker image remove ubuntu:16.04
$ docker image remove localhost:5000/my-ubuntu

GitLab Container Registry

Step 7 − Pull back the localhost:5000/my-ubuntu image from local registry −

$ docker pull localhost:5000/my-ubuntu

GitLab Container Registry

Step 8 − Now stop the registry and remove the data −

$ docker container stop registry && docker container rm -v registry

GitLab Container Registry



Advertisements

GitLab &-8211; Home

GitLab &-8211; Introduction

GitLab &-8211; Installation

GitLab &-8211; Git Commands

GitLab &-8211; SSH Key Setup

GitLab &-8211; Create Project

GitLab &-8211; Fork a Project

GitLab &-8211; Create a Branch

GitLab &-8211; Add a File

GitLab &-8211; Rebase Operation

GitLab &-8211; Squashing Commits

GitLab &-8211; Adding Users

GitLab &-8211; Create Groups

GitLab &-8211; Remove Users

GitLab &-8211; User Permissions

GitLab &-8211; Create Issue

GitLab &-8211; Merge Requests

GitLab &-8211; Referencing Issues

GitLab &-8211; Milestones

GitLab &-8211; Wiki Pages

GitLab &-8211; Create Backup

GitLab &-8211; Restore Backup

GitLab &-8211; Import Repository

GitLab CI &-8211; Introduction

GitLab &-8211; CI/CD

GitLab &-8211; CI/CD Variables

GitLab CI &-8211; Permissions

Configuring GitLab Runners

GitLab CI &-8211; Advanced usage of CI

GitLab CI &-8211; Cycle Analytics

GitLab CI &-8211; Container Registry

UPSC IAS Exams Notes

Developer&-8217;s Best Practices

Questions and Answers

Effective Resume Writing

HR Interview Questions

Computer Glossary

Who is Who

GitLab CI – Cycle Analytics

GitLab CI &-8211; Cycle Analytics &-8211; this Article or News was published on this date:2019-05-15 07:44:02 kindly share it with friends if you find it helpful

GitLab CI &-8211; Cycle Analytics


Advertisements


Description

Cycle Analytics specifies how much time taken by the team to complete the each stage in their workflow and allows GitLab to store data of development efforts in one central data store.

The cycle analytics page can be found under the Overview section.

Step 1 − Login to your GitLab account and go to your project −

GitLab Usage of CI

Step 2 − Click on the Cycle Analytics option under Overview tab which will open the screen as shown below −

GitLab Cycle Analytics

The cycle analytics contains following stages −

  • Issue − It specifies how much time taken to solve an issue.

  • Plan − It specifies the time between pushing first commit to branch and action took for previous stage.

  • Code − It specifies the time between pushing first commit to branch and created merge request for that commit.

  • Test − It specifies how much time need to GitLab CI/CD to test the code.

  • Review − It specifies time taken to review the merge request.

  • Staging − It defines the time spent between merging and deploying to production.

  • Production − It specifies the time taken to complete the entire process, from creating an issue to deploying code to production.



Advertisements

GitLab &-8211; Home

GitLab &-8211; Introduction

GitLab &-8211; Installation

GitLab &-8211; Git Commands

GitLab &-8211; SSH Key Setup

GitLab &-8211; Create Project

GitLab &-8211; Fork a Project

GitLab &-8211; Create a Branch

GitLab &-8211; Add a File

GitLab &-8211; Rebase Operation

GitLab &-8211; Squashing Commits

GitLab &-8211; Adding Users

GitLab &-8211; Create Groups

GitLab &-8211; Remove Users

GitLab &-8211; User Permissions

GitLab &-8211; Create Issue

GitLab &-8211; Merge Requests

GitLab &-8211; Referencing Issues

GitLab &-8211; Milestones

GitLab &-8211; Wiki Pages

GitLab &-8211; Create Backup

GitLab &-8211; Restore Backup

GitLab &-8211; Import Repository

GitLab CI &-8211; Introduction

GitLab &-8211; CI/CD

GitLab &-8211; CI/CD Variables

GitLab CI &-8211; Permissions

Configuring GitLab Runners

GitLab CI &-8211; Advanced usage of CI

GitLab CI &-8211; Cycle Analytics

GitLab CI &-8211; Container Registry

UPSC IAS Exams Notes

Developer&-8217;s Best Practices

Questions and Answers

Effective Resume Writing

HR Interview Questions

Computer Glossary

Who is Who

GitLab CI – Advanced usage of CI

GitLab CI &-8211; Advanced usage of CI &-8211; this Article or News was published on this date:2019-05-15 07:43:59 kindly share it with friends if you find it helpful

GitLab CI &-8211; Advanced usage of CI


Advertisements


Environments and Deployments

Environments are used for testing, building and deploying the CI (Continuous Integration) jobs and control the Continuous Deployment of software with the GitLab. GitLab CI is capable of tracking your project deployments and also you will come to know what is being deployed on your server.

The name of an environment could be defined by using environment:name string and contain the following −

  • letters
  • digits
  • spaces
  • &-8211;
  • _
  • /
  • $
  • {
  • }

Using SSH keys with GitLab CI/CD

You can set the SSH (Secure Shell or Secure Socket Shell) keys to provide a reliable connection between the computer and GitLab. The SSH keys can be used with GitLab CI/CD when −

  • You need to checkout internal sub modules.
  • You need to download private packages using package manager.
  • You need to install an application to your own server.
  • You execute the SSH commands to remote server from build environment.
  • You need to rsync files to a remote server from the build environment.

The SSH key setup is explained in the GitLab SSH Key Setup chapter.

Artifacts

Artifacts are used to attach the list of files and directories to the job after success. The artifacts contain following types −

  • artifacts:name − This directive is used to specify the name of created artifacts archive. It provides unique name for created artifacts archive which is helpful when you are downloading the archive from GitLab.
  • artifacts:when − This directive is used to upload artifacts when there is a job failure. It contains the following values:

    • on_success − It is used to upload the artifacts when there is a job success.
    • on_failure − It is used to upload the artifacts when the job fails.
    • always − It is used to upload the artifacts regardless of job status.
  • artifacts:expire_in − It defines that how long artifacts should live before they expire and therefore deleted, since they are uploaded and stored on GitLab

Triggering Pipelines

Triggers can force a specific branch or tag to get rebuilt with an API call and triggers with the legacy label will have access to the current project.

The new trigger can be added as shown in the below steps −

Step 1 − Login to your GitLab account and go to your project −

GitLab Usage of CI

Step 2 − Click on the CI/CD option under Settings tab and expand the Pipeline triggers option −

GitLab Usage of CI

Enter the description for the trigger and click on the Add Trigger button.

Step 3 − Next, it will display the success message after creating the trigger −

GitLab Usage of CI

Step 4 − Now go to CI/CD option under Settings tab and expand the Pipeline triggers option. You will see the newly created trigger along with the token as shown in the image below −

GitLab Usage of CI

Pipeline Schedules

You can run the pipeline by using the pipeline schedules at specific intervals. To create pipeline schedule, use the below steps −

Step 1 − Login to your GitLab account and go to your project −
GitLab Usage of CI

Step 2 − Click on the Schedules option under CI/CD tab and click on the New schedule button −

GitLab Usage of CI

Step 3 − Next, it will open the Scheduling new pipeline screen, fill up the fields and click on the Save pipeline schedule button −

GitLab Usage of CI

Step 4 − Now, you will see the pipeline which is scheduled to run −

GitLab Usage of CI

Connecting GitLab with a Kubernetes Cluster

The Kubernetes cluster can be used to review and deploy the applications, running the pipeline etc in an easy method. You can create a new cluster to your project by associating your GitLab account with the Google Kubernetes Engine (GKE).

The new Kubernetes cluster can be created as shown in the below steps −

Step 1 − Login to your GitLab account and go to your project −

GitLab Usage of CI

Step 2 − Click on the Kubernetes option under CI/CD tab −

GitLab Usage of CI

Step 3 − Next, click on Add Kubernetes cluster button −

GitLab Usage of CI

Step 4 − Click on Create on GKE button to create a new Kubernetes cluster on Google Kubernetes Engine −

GitLab Usage of CI

Step 5 − If you have a Google account, then sign with that account to enter the details for Kubernetes cluster or else create a new Google account −

GitLab Usage of CI

Step 6 − Now enter the values in the fields for your Kubernetes cluster −

GitLab Usage of CI

Step 7 − Before adding values in the fields, you need ID of the project which is created in the Google Cloud Platform console to host the Kubernetes cluster. To create ID, click on the See your projects link which is highlighted in the previous image. It will open the below screen, then click on My Project menu and click on the plus (+) icon to create a new project −

GitLab Usage of CI

Step 8 − Now enter the project name and click on the Create button −

GitLab Usage of CI

Step 9 − You will get the ID of the project which will host the Kubernetes cluster −

GitLab Usage of CI

Step 10 − Enter the values in the fields for your Kubernetes cluster along with the Google Cloud Platform project ID and click on the Create Kubernetes cluster button −

GitLab Usage of CI



Advertisements

GitLab &-8211; Home

GitLab &-8211; Introduction

GitLab &-8211; Installation

GitLab &-8211; Git Commands

GitLab &-8211; SSH Key Setup

GitLab &-8211; Create Project

GitLab &-8211; Fork a Project

GitLab &-8211; Create a Branch

GitLab &-8211; Add a File

GitLab &-8211; Rebase Operation

GitLab &-8211; Squashing Commits

GitLab &-8211; Adding Users

GitLab &-8211; Create Groups

GitLab &-8211; Remove Users

GitLab &-8211; User Permissions

GitLab &-8211; Create Issue

GitLab &-8211; Merge Requests

GitLab &-8211; Referencing Issues

GitLab &-8211; Milestones

GitLab &-8211; Wiki Pages

GitLab &-8211; Create Backup

GitLab &-8211; Restore Backup

GitLab &-8211; Import Repository

GitLab CI &-8211; Introduction

GitLab &-8211; CI/CD

GitLab &-8211; CI/CD Variables

GitLab CI &-8211; Permissions

Configuring GitLab Runners

GitLab CI &-8211; Advanced usage of CI

GitLab CI &-8211; Cycle Analytics

GitLab CI &-8211; Container Registry

UPSC IAS Exams Notes

Developer&-8217;s Best Practices

Questions and Answers

Effective Resume Writing

HR Interview Questions

Computer Glossary

Who is Who

GitLab CI – Configuring Gitlab Runners

GitLab CI &-8211; Configuring Gitlab Runners &-8211; this Article or News was published on this date:2019-05-15 07:43:57 kindly share it with friends if you find it helpful

GitLab CI &-8211; Configuring Gitlab Runners


Advertisements


Description

GitLab runner is a build instance which is used to run the jobs over multiple machines and send the results to GitLab and which can be placed on separate users, servers, and local machine. You can register the runner as shared or specific after installing it. The installation of runner is explained in the GitLab Installation chapter.

You can serve your jobs by using either specific or shared runners.

Shared Runners

These runners are useful for jobs multiple projects which have similar requirements. Instead of using multiple runners for many projects, you can use a single or a small number of Runners to handle multiple projects which will be easy to maintain and update.

Specific Runners

These runners are useful to deploy a certain project, if jobs have certain requirements or specific demand for the projects. Specific runners use FIFO (First In First Out) process for organizing the data with first-come first-served basis.

You can register a specific runner by using project registration token. The registering a specific runner is explained in the GitLab Installation chapter from step 1 to 12 under the Installation of GitLab on Windows section.

Locking a specific Runner

You can lock a specific runner from being enabled for other projects. To do this, you need to register a runner which is explained in the GitLab Installation chapter from step 1 to 12 under the Installation of GitLab on Windows section.

To lock runner, execute the below steps −

Step 1 − Login to your GitLab account and go to your project −
GitLab Installation

Step 2 − Click on the CI/CD option under Settings tab and expand the Runners Settings option. −

GitLab Installation

Step 3 − Under Runners Settings section, you will see the activated Runners for the project −

GitLab Installation

Step 4 − Now click on the pencil button −

GitLab Runner

Step 5 − Next it will open the Runner screen and check the Lock to current projects option −

GitLab Runner

Click on the Save changes button to take the changes effect.

Step 6 − After saving the changes, it will update the Runner successfully.

GitLab Runner

Protected Runners

The runners can be protected to save the important information. You can protect the runner by using below steps −

Step 1 − Follow the same steps (from step 1 to 4) which are explained in the previous section (Locking a specific Runner).

Step 2 − After clicking on the pencil button, it will open the Runner screen and then check the Protected option −

GitLab Installation

Click on the Save changes button to take the changes effect.

Run untagged Jobs

You can prevent runners from picking jobs with tags when there are no tags assigned to runners. Runner can pick tagged/untagged jobs by using below steps −

Step 1 − Follow the same steps (from step 1 to 4) which are explained in the Locking a specific Runner section.

Step 2 − After clicking on the pencil button, it will open the Runner screen and then check the Run untagged jobs option −

GitLab Installation

Click on the Save changes button to take the changes effect.



Advertisements

GitLab &-8211; Home

GitLab &-8211; Introduction

GitLab &-8211; Installation

GitLab &-8211; Git Commands

GitLab &-8211; SSH Key Setup

GitLab &-8211; Create Project

GitLab &-8211; Fork a Project

GitLab &-8211; Create a Branch

GitLab &-8211; Add a File

GitLab &-8211; Rebase Operation

GitLab &-8211; Squashing Commits

GitLab &-8211; Adding Users

GitLab &-8211; Create Groups

GitLab &-8211; Remove Users

GitLab &-8211; User Permissions

GitLab &-8211; Create Issue

GitLab &-8211; Merge Requests

GitLab &-8211; Referencing Issues

GitLab &-8211; Milestones

GitLab &-8211; Wiki Pages

GitLab &-8211; Create Backup

GitLab &-8211; Restore Backup

GitLab &-8211; Import Repository

GitLab CI &-8211; Introduction

GitLab &-8211; CI/CD

GitLab &-8211; CI/CD Variables

GitLab CI &-8211; Permissions

Configuring GitLab Runners

GitLab CI &-8211; Advanced usage of CI

GitLab CI &-8211; Cycle Analytics

GitLab CI &-8211; Container Registry

UPSC IAS Exams Notes

Developer&-8217;s Best Practices

Questions and Answers

Effective Resume Writing

HR Interview Questions

Computer Glossary

Who is Who

GitLab CI – Permissions

GitLab CI &-8211; Permissions &-8211; this Article or News was published on this date:2019-05-15 07:43:56 kindly share it with friends if you find it helpful

GitLab CI &-8211; Permissions


Advertisements


User Permissions

The following table shows available user permissions levels for different types of users in a project −

S.N. Guest Reporter Developer Master Owner
1 Creates a new issue Creates a new issue Creates a new issue Creates a new issue Creates a new issue
2 Can leave comments Can leave comments Can leave comments Can leave comments Can leave comments
3 Able to write on project wall Able to write on project wall Able to write on project wall Able to write on project wall Able to write on project wall
4 &-8211; Able to pull project code Able to pull project code Able to pull project code Able to pull project code
5 &-8211; Can download project Can download project Can download project Can download project
6 &-8211; Able to write code snippets Able to write code snippets Able to write code snippets Able to write code snippets
7 &-8211; &-8211; Create new merge request Create new merge request Create new merge request
8 &-8211; &-8211; Create new branch Create new branch Create new branch
9 &-8211; &-8211; Push and remove non protected branches Push and remove non protected branches Push and remove non protected branches
10 &-8211; &-8211; Includes tags Includes tags Includes tags
11 &-8211; &-8211; Can create, edit, delete project milestones Can create, edit, delete project milestones Can create, edit, delete project milestones
12 &-8211; &-8211; Can create or update commit status Can create or update commit status Can create or update commit status
13 &-8211; &-8211; Write a wiki Write a wiki Write a wiki
14 &-8211; &-8211; Create new environments Create new environments Create new environments
15 &-8211; &-8211; Cancel and retry the jobs Cancel and retry the jobs Cancel and retry the jobs
16 &-8211; &-8211; Updates and removes the registry image Updates and removes the registry image Updates and removes the registry image
17 &-8211; &-8211; &-8211; Can add new team members Can add new team members
18 &-8211; &-8211; &-8211; Push and remove protected branches &-8211;
19 &-8211; &-8211; &-8211; Can edit the project Can edit the project
20 &-8211; &-8211; &-8211; Can manage runners, job triggers and variables Can manage runners, job triggers and variables
21 &-8211; &-8211; &-8211; Add deploy keys to project Add deploy keys to project
22 &-8211; &-8211; &-8211; Able to manage clusters Able to manage clusters
23 &-8211; &-8211; &-8211; Configure project hooks Configure project hooks
24 &-8211; &-8211; &-8211; Can enable/disable the branch protection Can enable/disable the branch protection
25 &-8211; &-8211; &-8211; Able to rewrite or remove Git tags Able to rewrite or remove Git tags

The following table shows available group members permissions levels in a group −

S.N. Guest Reporter Developer Master Owner
1 Browse group Browse group Browse group Browse group Browse group
2 &-8211; &-8211; &-8211; &-8211; Edit group
3 &-8211; &-8211; &-8211; &-8211; Create subgroup
4 &-8211; &-8211; &-8211; Create project in group Create project in group
5 &-8211; &-8211; &-8211; &-8211; Manage group members
6 &-8211; &-8211; &-8211; &-8211; Remove group
7 &-8211; Manage group labels Manage group labels Manage group labels Manage group labels
8 &-8211; &-8211; Create/edit/delete group milestones Create/edit/delete group milestones Create/edit/delete group milestones
9 &-8211; View private group epic View private group epic View private group epic View private group epic
10 &-8211; &-8211; &-8211; &-8211; &-8211;
11 View internal group epic View internal group epic View internal group epic View internal group epic View internal group epic
12 View public group epic View public group epic View public group epic View public group epic View public group epic
13 &-8211; Create/edit group epic Create/edit group epic Create/edit group epic Create/edit group epic
14 &-8211; &-8211; &-8211; &-8211; Delete group epic
15 &-8211; &-8211; &-8211; &-8211; View group Audit Events

The following table shows available GitLab CI/CD permissions in the GitLab −

S.N. Guest/Reporter Developer Master Admin
1 Can see commits and jobs Can see commits and jobs Can see commits and jobs Can see commits and jobs
2 Retry or cancel job Retry or cancel job Retry or cancel job
3 &-8211; Deletes job artifacts and trace Deletes job artifacts and trace Deletes job artifacts and trace
4 &-8211; &-8211; Remove project Remove project
5 &-8211; &-8211; Create project Create project
6 &-8211; &-8211; Change project configuration Change project configuration
7 &-8211; &-8211; Add specific runners Add specific runners
8 &-8211; &-8211; &-8211; Add shared runners
9 &-8211; &-8211; &-8211; Can able to see events in the system
10 &-8211; &-8211; &-8211; Admin interface

Job Permissions

The following table shows job permissions in the GitLab −

S.N. Guest/Reporter Developer Master Admin
1 &-8211; Run CI job Run CI job Run CI job
2 &-8211; Clone source and LFS from current project Clone source and LFS from current project Clone source and LFS from current project
3 &-8211; Clone source and LFS from public projects Clone source and LFS from public projects Clone source and LFS from public projects
4 &-8211; Clone source and LFS from internal projects Clone source and LFS from internal projects Clone source and LFS from internal projects
5 &-8211; Clone source and LFS from private projects Clone source and LFS from private projects Clone source and LFS from private projects
6 &-8211; Push source and LFS Push source and LFS Push source and LFS
7 &-8211; Pull container images from current project Pull container images from current project Pull container images from current project
8 &-8211; Pull container images from public projects Pull container images from public projects Pull container images from public projects
9 &-8211; Pull container images from internal projects Pull container images from internal projects Pull container images from internal projects
10 &-8211; Pull container images from private projects Pull container images from private projects Pull container images from private projects
11 &-8211; Push container images to current project Push container images to current project Push container images to current project
12 &-8211; Push container images to other projects Push container images to other projects Push container images to other projects

Note − LFS stands for Large File Storage which is a Git extension that exchanges the large files such as audio, video, graphics with tiny pointers files in your repository.



Advertisements

GitLab &-8211; Home

GitLab &-8211; Introduction

GitLab &-8211; Installation

GitLab &-8211; Git Commands

GitLab &-8211; SSH Key Setup

GitLab &-8211; Create Project

GitLab &-8211; Fork a Project

GitLab &-8211; Create a Branch

GitLab &-8211; Add a File

GitLab &-8211; Rebase Operation

GitLab &-8211; Squashing Commits

GitLab &-8211; Adding Users

GitLab &-8211; Create Groups

GitLab &-8211; Remove Users

GitLab &-8211; User Permissions

GitLab &-8211; Create Issue

GitLab &-8211; Merge Requests

GitLab &-8211; Referencing Issues

GitLab &-8211; Milestones

GitLab &-8211; Wiki Pages

GitLab &-8211; Create Backup

GitLab &-8211; Restore Backup

GitLab &-8211; Import Repository

GitLab CI &-8211; Introduction

GitLab &-8211; CI/CD

GitLab &-8211; CI/CD Variables

GitLab CI &-8211; Permissions

Configuring GitLab Runners

GitLab CI &-8211; Advanced usage of CI

GitLab CI &-8211; Cycle Analytics

GitLab CI &-8211; Container Registry

UPSC IAS Exams Notes

Developer&-8217;s Best Practices

Questions and Answers

Effective Resume Writing

HR Interview Questions

Computer Glossary

Who is Who