本文爲[原創]文章,轉載請標明出處。
原文連接: https://weyunx.com/2019/01/23...
原文出自 微雲的技術博客
下載安裝包linux
# Linux x86-64 sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 # Linux x86 sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386 # Linux arm sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm
若是是離線安裝的話,能夠手工聯網下載,而後放到內網中,放到/usr/local/bin
目錄下,並命名爲gitlab-runner
git
# 賦予可執行權限 sudo chmod +x /usr/local/bin/gitlab-runner # 建立 GitLab CI 用戶 sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash # 安裝 sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner # 運行 sudo gitlab-runner start
首先須要準備URL和Token,能夠在 GitLab 項目的 settings->CI/CD->Runners settings
中找到docker
# 註冊 sudo gitlab-runner register # 輸入本地的 gitlab URL Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com ) https://gitlab.com # 輸入 Token Please enter the gitlab-ci token for this runner xxx # 輸入 tag, 注意要跟 job 的 tag 一致,後續詳細說明 Please enter the gitlab-ci tags for this runner (comma separated): my-tag,another-tag # 選擇 executor, Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell: docker
Runner 默認只會在配置了和自身 tags 一致的項目上運行,是爲了防止 Runner 運行在大量項目上出現問題。shell
同時能夠在 Runner 中取消該設置,容許 Runner 運行在無 tags 的項目上,配置以下bash
- Visit your project’s Settings ➔ CI/CD
- Find the Runner you wish and make sure it’s enabled
- Click the pencil button
- Check the Run untagged jobs option
- Click Save changes for the changes to take effect
Executor | SSH | Shell | VirtualBox | Parallels | Docker | Kubernetes |
---|---|---|---|---|---|---|
Clean build environment for every build | ✗ | ✗ | ✓ | ✓ | ✓ | ✓ |
Migrate runner machine | ✗ | ✗ | partial | partial | ✓ | ✓ |
Zero-configuration support for concurrent builds | ✗ | ✗ (1) | ✓ | ✓ | ✓ | ✓ |
Complicated build environments | ✗ | ✗ (2) | ✓ (3) | ✓ (3) | ✓ | ✓ |
Debugging build problems | easy | easy | hard | hard | medium | medium |
- It’s possible, but in most cases it is problematic if the build uses services installed on the build machine
- It requires to install all dependencies by hand
- For example using Vagrant
具體詳細可參考這裏ssh
在 GitLab 項目中新增.gitlab-ci.yml
,能夠選擇預先設置好的模版。gitlab
未完待續...ui