CentOS7 に Giitlab Runnerをインストールして登録する

Linux

今日はGitLabダウンしてたみたいですね。

まずはダウンロードします
$ sudo curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash

以下、ダウンロード
[sudo] password for contos: [パスワード入力]
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7016 100 7016 0 0 18477 0 --:--:-- --:--:-- --:--:-- 18511
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: https://packages.gitlab.com/install/repositories/runner/gitlab-runner/config_file.repo?os=centos&dist=7&source=script
done.
Installing pygpgme to verify GPG signatures...
Failed to set locale, defaulting to C
Loaded plugins: copr, fastestmirror, langpacks
Determining fastest mirrors
epel/x86_64/metalink | 8.1 kB 00:00
* base: mirrors.cat.net
* epel: repo.jing.rocks
* extras: mirrors.cat.net
* remi-safe: cdn.centos.no
* updates: mirrors.cat.net
base | 3.6 kB 00:00:00
copr:copr.fedorainfracloud.org:ngompa:snapcore-el7 | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
nodesource | 2.5 kB 00:00:00
remi-safe | 3.0 kB 00:00:00
runner_gitlab-runner-source/signature | 862 B 00:00:00
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Importing GPG key 0x51312F3F:
Userid : "GitLab B.V. (package repository signing key) "
Fingerprint: f640 3f65 44a3 8863 daa0 b6e0 3f01 618a 5131 2f3f
From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-4C80FB51394521E9.pub.gpg
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-49F16C5CC3A0F81F.pub.gpg
runner_gitlab-runner-source/signature | 951 B 00:00:01 !!!
updates | 2.9 kB 00:00:00
(1/4): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(2/4): remi-safe/primary_db | 2.5 MB 00:00:00 (3/4): epel/x86_64/primary_db | 7.0 MB 00:00:01
(4/4): updates/7/x86_64/primary_db | 23 MB 00:00:02
runner_gitlab-runner-source/primary | 175 B 00:00:01
Package pygpgme-0.3-9.el7.x86_64 already installed and latest version
Nothing to do
Installing yum-utils...
Failed to set locale, defaulting to C
Loaded plugins: copr, fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.cat.net
* epel: repo.jing.rocks
* extras: mirrors.cat.net
* remi-safe: cdn.centos.no
* updates: mirrors.cat.net
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do
Generating yum cache for runner_gitlab-runner...
Failed to set locale, defaulting to C
Importing GPG key 0x51312F3F:
Userid : "GitLab B.V. (package repository signing key) "
Fingerprint: f640 3f65 44a3 8863 daa0 b6e0 3f01 618a 5131 2f3f
From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Generating yum cache for runner_gitlab-runner-source...
Failed to set locale, defaulting to C
The repository is setup! You can now install packages.
$

インストールできるよと言われているのでインストールします


$ sudo yum install -y gitlab-runner

↓こんな感じでインストール始まりました


Failed to set locale, defaulting to C
Loaded plugins: copr, fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.cat.net
* epel: repo.jing.rocks
* extras: mirrors.cat.net
* remi-safe: cdn.centos.no
* updates: mirrors.cat.net
Resolving Dependencies
--> Running transaction check
---> Package gitlab-runner.x86_64 0:16.4.1-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================
Installing:
gitlab-runner x86_64 16.4.1-1 runner_gitlab-runner 461 M

Transaction Summary
===============================================================================================================================================
Install 1 Package

Total download size: 461 M
Installed size: 502 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/runner_gitlab-runner/packages/gitlab-runner-16.4.1-1.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 6ba75a4e: NOKEY==================-] 11 MB/s | 460 MB 00:00:00 ETA
Public key for gitlab-runner-16.4.1-1.x86_64.rpm is not installed
gitlab-runner-16.4.1-1.x86_64.rpm | 461 MB 00:00:44
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Importing GPG key 0x51312F3F:
Userid : "GitLab B.V. (package repository signing key) "
Fingerprint: f640 3f65 44a3 8863 daa0 b6e0 3f01 618a 5131 2f3f
From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-4C80FB51394521E9.pub.gpg
Importing GPG key 0x35DFA027:
Userid : "GitLab, Inc. "
Fingerprint: 09e5 7083 f34c ca94 d541 bc58 a674 bf81 35df a027
From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-4C80FB51394521E9.pub.gpg
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-49F16C5CC3A0F81F.pub.gpg
Importing GPG key 0x6BA75A4E:
Userid : "GitLab, Inc. "
Fingerprint: 931d a69c fa3a febb c97d aa8c 6c57 c29c 6ba7 5a4e
From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-49F16C5CC3A0F81F.pub.gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : gitlab-runner-16.4.1-1.x86_64 [####################################################################################################################### Installing : gitlab-runner-16.4.1-1.x86_64 [######################################################################################################################## Installing : gitlab-runner-16.4.1-1.x86_64 [########################################################################################################################## Installing : gitlab-runner-16.4.1-1.x86_64 1/1
GitLab Runner: creating gitlab-runner...
Home directory skeleton not used
Runtime platform arch=amd64 os=linux pid=17698 revision=d89a789a version=16.4.1
gitlab-runner: the service is not installed
Runtime platform arch=amd64 os=linux pid=17703 revision=d89a789a version=16.4.1
gitlab-ci-multi-runner: the service is not installed
Runtime platform arch=amd64 os=linux pid=17715 revision=d89a789a version=16.4.1
Runtime platform arch=amd64 os=linux pid=17763 revision=d89a789a version=16.4.1
INFO: Docker installation not found, skipping clear-docker-cache
Verifying : gitlab-runner-16.4.1-1.x86_64 1/1

Installed:
gitlab-runner.x86_64 0:16.4.1-1
Complete!
$

確認してみます
$ sudo gitlab-runner --version
[sudo] password for centos: [パスワード]
Version: 16.4.1
Git revision: d89a789a
Git branch: 16-4-stable
GO version: go1.20.5
Built: 2023-10-06T01:26:25+0000
OS/Arch: linux/amd64
$

$ sudo gitlab-runner status
[sudo] password for centos: [パスワード]
Runtime platform arch=amd64 os=linux pid=18832 revision=d89a789a version=16.4.1
gitlab-runner: Service is running
$

インストールはされたっぽい

次は登録します

gitlabの「設定」→「CI/CD]を開いて「Runner」を展開します。

「新規プロジェクトRunner」をクリックします
新規作成画面になりますので
タグに何か入れて「作成」をクリックします

するとrunnerが作成されます

このトークンをクリップボードにコピーしておきます
$ sudo gitlab-runner register
[sudo] password for centos:[パスワード入力]
Runtime platform arch=amd64 os=linux pid=19417 revision=d89a789a version=16.4.1
Running in system-mode.

gitlabのインスタンスのURLを求められます。
言われている通りhttps://gitlab.com/ と入力します。
Enter the GitLab instance URL (for example, https://gitlab.com/):
https://gitlab.com/

するとトークンを求められるので、先ほど作成したトークンをペーストします。
Enter the registration token:
tokenTOKENtokenTOKENtokenTOKEN
Verifying runner... is valid runner=RunnerIDppoi

こんどはRunnerに名前をつけてくださいと言われます。
my-runnerとか入れておきます。
Enter a name for the runner. This is stored only in the local config.toml file:
: my-runner

実行環境を決めてくださいと言われます。
shellにしときます。
Enter an executor: virtualbox, docker-autoscaler, docker+machine, custom, docker, docker-windows, parallels, ssh, kubernetes, shell, instance:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml"

先ほどの「設定」→「CI/CD」 Runnerを展開すると登録したRunnerを見ることができます。

コメント

タイトルとURLをコピーしました