Gitlab CI configuration pipeline deployment

brief introduction

Basic concepts

GitLab-CI

GitLab CI is GitLab Continuous Integration, which is GitLab's own continuous integration tool.
The idea is to trigger execution of gitlab-ci.yml script every time the user push es the code to GitLab. The content of the script includes a series of customized content such as test, compilation, deployment, etc.

GitLab-Runner

install

$ curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash

$ sudo yum install gitlab-ci-multi-runner

For details, please refer to GitLab runner official website installation tutorial

register

Registering a Runner with gitlab CI requires two things: the url of gitlab Ci and the registration token. Can be found in the project code warehouse

After finding the token, run the following command to register the Runner

$ sudo gitlab-ci-multi-runner register

Follow the prompts to enter the URL

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )
https://gitlab.com

Input token

Enter the token you obtained to register the Runner:
Please enter the gitlab-ci token for this runner
xxx

Enter a description (this description can be modified on the interface later)

Enter a description for the Runner, you can change this later in GitLab's UI:
Please enter the gitlab-ci description for this runner
[hostame] my-runner

Enter the tag related to the runner. gitlab-ci.yml can trigger the runner to build the pipeline task through this tag (you can also modify it in the interface later here)

Enter the tags associated with the Runner, you can change this later in GitLab's UI:
Please enter the gitlab-ci tags for this runner (comma separated):
my-tag,another-tag

Whether to allow task execution without tag

Choose whether the Runner should pick up jobs that do not have tags, you can change this later in GitLab's UI (defaults to false):
Whether to run untagged jobs [true/false]:
[false]: true

Whether to lock the Runner for the current project

Choose whether to lock the Runner to the current project, you can change this later in GitLab's UI. Useful when the Runner is specific (defaults to true):
Whether to lock Runner to current project [true/false]:
[true]: true

Select the Runner's actuator

Enter the Runner executor:
Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
shell

If docker is selected in the previous step, this step needs to be filled in

If you chose Docker as your executor, you'll be asked for the default image to be used for projects that do not define one in .gitlab-ci.yml:
Please enter the Docker image (eg. ruby:2.1):
alpine:latest

For details, please refer to Official documents

After the registration is completed, gitlab CI will generate a new Runner record. Gitlab CI will generate a unique token for the Runner, through which the Runner will communicate with gitlab CI.
Then click the button in Shared Runners on the right side of the page to change the button status to Disabled Shared Runners.

$ sudo gitlab-ci-multi-runner list/verify

To configure

gitlab-ci.yml

This is a file under the root directory of git project, which records a series of stages and execution rules, including a series of execution scripts and the specified runner name. Gitlab CI will parse it after push ing, and call runner to run it according to its contents.

For details, please refer to Official documents

start-up

Sudo gitlab CI multi runner start
Sudo gitlab CI multi runner run foreground start
Sudo gitlab CI multi runner status view status
sudo gitlab-runner -debug run: the foreground is started (debugging mode, log will be output in the console)

29 original articles published, 76 praised, 270000 visitors+
Private letter follow

Tags: GitLab Docker sudo ssh

Posted on Tue, 14 Jan 2020 20:29:48 -0800 by disaster77