GITLAB CIランナーをセットアップ
私たちは、Gitlabのインフラストラクチャであなたの仕事を走らせる共有ランナーを使用して、あなたの仕事を調整するGitlab CIとともに、Aをセットアップするセットアップを経験しました.
GitLabでは、ランナーを共有して、あなたの仕事を実行し、GitLabに結果を送信するために使用される独自のランナーを実行する機能を持っている.
このチュートリアルでは、セットアップをgbunlabランナーとDocBakerとUbuntuのサーバーをセットアップし、あなたのGitLabランナーを利用するための基本的なパイプラインを設定します.
関連記事
セットアップDocker
Dockerをインストールします
$ sudo apt update && sudo apt upgrade -y
$ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ sudo apt update
$ sudo apt install docker-ce -y
$ docker run hello-world
インストールとセットアップ
この設定はLinux 64 bit用で、他のディストリビューション向けにはdocs
ランナーをインストール
$ wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
$ chmod +x /usr/local/bin/gitlab-runner
$ useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
$ gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
$ gitlab-runner start
ランナーを登録しなさい.GITLAB CIトークンは、UIからCCI/CD設定パネルで使用できます.https://gitlab.com/<account>/<repo>/settings/ci_cd
$ gitlab-runner register
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://gitlab.com/
Please enter the gitlab-ci token for this runner:
__masked__
Please enter the gitlab-ci description for this runner:
[my-runner]: my-runner
Please enter the gitlab-ci tags for this runner (comma separated):
my-runner,foobar
Registering runner... succeeded runner=66m_339h
Please enter the executor: docker-ssh+machine, docker, docker-ssh, parallels, shell, ssh, virtualbox, docker+machine, kubernetes:
docker
Please enter the default Docker image (e.g. ruby:2.1):
alpine:latest
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
ステータスを確認し、起動時にDockerとGitLabランナーが有効になっているかどうかを確認します.$ gitlab-runner status
Runtime platform arch=amd64 os=linux pid=30363 revision=7f00c780 version=11.5.1
gitlab-runner: Service is running!
$ systemctl is-enabled gitlab-runner
enabled
$ systemctl is-enabled docker
enabled
共有ランナーのためのgitlab ci config
GitLabが提供する共有ランナーを使用したい場合は
.gitlab-ci.yml
これは次のようになります.stages:
- build
- test
build:
stage: build
script:
- echo "this is building"
- hostname
- mkdir builds
- touch builds/data.txt
- echo "true" > builds/data.txt
artifacts:
paths:
- builds/
test:
stage: test
script:
- echo "this is testing"
- hostname
- test -f builds/data.txt
- grep "true" builds/data.txt
GitLab CIの独自のgitlabランナー
GitLabは、ジョブの実行場所を決定するために登録に指定されたタグを利用しますdocs
The
.gitlab-ci.yml
GitLabランナーを使用するための設定stages:
- build
- test
build:
stage: build
tags:
- my-runner
script:
- echo "this is building"
- hostname
- mkdir builds
- touch builds/data.txt
- echo "true" > builds/data.txt
artifacts:
paths:
- builds/
test:
stage: test
tags:
- my-runner
script:
- echo "this is testing"
- hostname
- test -f builds/data.txt
- grep "true" builds/data.txt
トリガチェック
マスターに設定をコミットし、パイプラインが完了したらジョブを実行させましょう.ジョブが実行されたコンテナ用のサーバー上のDockerを見てください.
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
04292a78de0b c04b8be95e1e "gitlab-runner-cache.." About a minute ago Exited (0) About a minute ago runner-xx-project-xx-concurrent-0-cache-3cxx0
49b1b3c4adf9 c04b8be95e1e "gitlab-runner-cache.." About a minute ago Exited (0) About a minute ago runner-xx-project-xx-concurrent-0-cache-6cxxa
422b23191e8c hello-world "/hello" 24 minutes ago Exited (0) 24 minutes ago wizardly_meninsky
各ジョブが異なるコンテナで実行されるのを知っているので、上記の出力から、パイプラインで指定された2つのジョブに対して2つの異なるコンテナがあることがわかります.リソース
ありがとう
あなたが何を考えるかについて知らせてください.あなたが私の内容が好きならば、私を訪問してくださいruan.dev またはTwitterで私に従ってください
Reference
この問題について(GITLAB CIランナーをセットアップ), 我々は、より多くの情報をここで見つけました https://dev.to/ruanbekker/setup-a-gitlab-ci-runner-on-your-own-server-4p2jテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol