前言

什么是CI/CD?

CI (Continuous Integration) 持续集成, CD (Continuous Delivery) 持续部署

个人理解

本地开发代码, 提交远程仓库

仓库接收到提交操作,进入持续集成, 包括编译,自动化测试 (CI)

编译测试成功后,部署到线上服务器(CD)

gitlab-runner 介绍

gitlab 提供了一个持续集成的服务, 如果你在项目仓库里面加入.gitlab-ci.yml文件 同时给项目配置了gitlab-runner, 那么每一次push commit, 都会触发你的 CI pipeline (持续集成管道)

安装gitlab-runner

官方文档

代理安装 gitlab-runner

如果机器能够正常访问外网,那么查阅官方文档进行安装

一般来说,内网与外网是处于隔断的情况,但是可以通过http代理服务器,允许内网访问外网的资源。

假设代理服务器机器的ip为: http://192.168.1.100:8000

具体步骤:

编辑 yum.conf

sudo vi /etc/yum.conf

# 追加一行
proxy=http://192.168.1.100:8000 #添加 GitLab's official repository (yum仓库) http_proxy=http://192.168.1.100:8000 curl -L -x $http_proxy https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sed "s#curl -sSf#curl -x $http_proxy -sSf#g" > script.rpm.sh
sudo bash script.rpm.sh

下载安装gitlab

# 查看gitlab-runner的版本
yum list gitlab-runner --showduplicates | sort -r gitlab-runner.x86_64 10.5.0-1 runner_gitlab-runner
gitlab-runner.x86_64 10.4.0-1 runner_gitlab-runner
gitlab-runner.x86_64 10.3.1-1 runner_gitlab-runner
gitlab-runner.x86_64 10.3.0-1 runner_gitlab-runner
gitlab-runner.x86_64 10.2.1-1 runner_gitlab-runner
gitlab-runner.x86_64 10.2.0-1 runner_gitlab-runner
gitlab-runner.x86_64 10.1.1-1 runner_gitlab-runner
gitlab-runner.x86_64 10.1.0-1 runner_gitlab-runner
gitlab-runner.x86_64 10.0.2-1 runner_gitlab-runner
gitlab-runner.x86_64 10.0.1-1 runner_gitlab-runner
gitlab-runner.x86_64 10.0.0-1 runner_gitlab-runner # 指定安装某个版本
sudo yum install gitlab-runner-10.1.1-1 -y

安装完成后, 出现一个/home/gitlab-runner 文件夹

gitlab-runner 命令

主要的命令操作有如下: install, start, stop, status, register, unregister

install 命令

安装配置 gitlab-runner, 如果使用yum install 则会默认安装

# --user 用户名
# --working-directory 工作目录
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner

start 命令

sudo gitlab-runner start, 启动服务

stop 命令

sudo gitlab-runner stop, 关闭服务

status 命令

sudo gitlab-runner status, 查看服务运行状态

在仓库中查阅CI / CD Setting, 得到 CI token

sudo 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:
gHKt7inn3nBzJ2m5gx-P Please enter the gitlab-ci description for this runner:
hostname Please enter the gitlab-ci tags for this runner (comma separated):
node,test Whether to run untagged builds [true/false]:
true Whether to lock the Runner to current project [true/false]:
false Registering runner... succeeded runner=gHKt7inn
Please enter the executor: docker+machine, kubernetes, docker-ssh, ssh, shell, virtualbox, docker-ssh+machine, docker, parallels:
shell

注册后使用 gitlab-runner list 查阅配置

sudo gitlab-runner list
Listing configured runners ConfigFile=/etc/gitlab-runner/config.toml
hostname Executor=shell Token=token URL=https://gitlab.com/

注册后,gitlab 页面将出现一个运行的runner

gitlab-runner unregister 命令

通过 url 和 token 取消注册 gitlab-runner unregister --url http://gitlab.example.com/ --token t0k3n

通过name取消注册 gitlab-runner unregister --name test-runner

删除所有注册runner gitlab-runner unregister --all-runners

gitlab-ci-runner安装的更多相关文章

  1. Docker搭建自己的Gitlab CI Runner

    转载自:https://cloud.tencent.com/developer/article/1010595 1.Gitlab CI介绍 CI:持续集成,我们通常使用CI来做一些自动化工作,比如程序 ...

  2. 在 Kubernetes 上安装 Gitlab CI Runner Gitlab CI 基本概念以及 Runner 的安装

    简介 从 Gitlab 8.0 开始,Gitlab CI 就已经集成在 Gitlab 中,我们只要在项目中添加一个.gitlab-ci.yml文件,然后添加一个Runner,即可进行持续集成.在介绍 ...

  3. 3.在 Kubernetes 上安装 Gitlab CI Runner

    结合文章:1. 在 Kubernetes 上安装 Gitlab ,地址:https://www.cnblogs.com/sanduzxcvbnm/p/13852854.html 总结: 结合开头的文章 ...

  4. K8s 部署 Gitlab CI Runner

    K8s 版本:1.20.6 GitLab CI 最大的作用是管理各个项目的构建状态.因此,运行构建任务这种浪费资源的事情交给一个独立的 Gitlab Runner 来做就会好很多,而且 Gitlab ...

  5. GitLab CI runner can't connect to tcp://localhost:2375 in kubernetes

    报错的.gitlab-ci.yml配置如下 image: docker:latest services: - docker:dind variables: DOCKER_HOST: tcp://loc ...

  6. 使用GitLab CI + Capistrano部署CakePHP应用程序

    使用GitLab CI + Capistrano部署CakePHP应用程序 摘要:本文描述了如使用GitLab CI + Capistrano部署CakePHP应用程序. 目录 1. 问题2. 解决方 ...

  7. Gitlab CI持续集成 - GitLab Runner 安装与注册

    GitLab Runner安装 需要添加gitlab官方库: # For Debian/Ubuntu/Mint curl -L https://packages.gitlab.com/install/ ...

  8. Ubuntu Docker 安装和配置 GitLab CI 持续集成

    相关文章: Ubuntu Docker 简单安装 GitLab 劈荆斩棘:Gitlab 部署 CI 持续集成 目的:在 Ubuntu 服务器上,使用 Docker 安装和配置 GitLab Runne ...

  9. [转] Gitlab 8.x runner安装与配置

    [From]http://muchstudy.com/2018/07/13/Gitlab-8-x-runner%E5%AE%89%E8%A3%85%E4%B8%8E%E9%85%8D%E7%BD%AE ...

  10. docker-Gitlab、GitLab Runner安装

    以下操作均在CentOs下操作 1.Gitlab install ① 启动gitlab docker run --detach \ --hostname 115.30.149.35 \ --publi ...

随机推荐

  1. FileReader对象异步获取外部文件的内容

    1.在网页表单中,定义input的type为file,就可以打开存储在计算机上的文件. <!DOCTYPE html> <head> <meta charset=&quo ...

  2. 每天几分钟跟小猫学前端之node系列:用node实现最简单的爬虫

    先来段求分小视频: https://www.iesdouyin.com/share/video/6550631947750608142/?region=CN&mid=6550632036246 ...

  3. List,Set,Map三种接口的区别

    set --其中的值不允许重复,无序的数据结构 list   --其中的值允许重复,因为其为有序的数据结构  map--成对的数据结构,健值必须具有唯一性(键不能同,否则值替换)   List按对象进 ...

  4. MVC3 项目总结

    验证 Validation 多样化验证规则 http://www.cnblogs.com/xling/archive/2012/07/11/2587002.html 最常见的验证方式是:在实体的属性上 ...

  5. 轻松解决oracle11g 空表不能exp导出的问题

    轻松解决oracle11g 空表不能exp导出的问题 [引用 2012-9-22 18:06:36]     字号:大 中 小 oracle11g的新特性,数据条数是0时不分配segment,所以就不 ...

  6. 获取redis主从复制链SHELL脚本

    获取redis主从复制链SHELL脚本 vi redisnode.sh #!/bin/sh master_host=$ master_port=$ auth=$ #判断输入密码是否为空,为空则转化为' ...

  7. mysql经典面试题

    数据库优化:这个优化法则归纳为5个层次:1. 减少数据访问(减少磁盘访问)2. 返回更少数据(减少网络传输或磁盘访问)3. 减少交互次数(减少网络传输)4. 减少服务器CPU开销(减少CPU及内存开销 ...

  8. Java main方法全解

    1.main方法的重载 package cn.nxl2018; public class Main_test { public static void main(String args[]) { Sy ...

  9. MVC-AOP(面向切面编程)思想-Filter之IExceptionFilter-异常处理

    HandleErrorAttribute MVC中的基本异常分类: Action异常      T view异常 T, service异常     T, 控制器异常      F(异常get不到), ...

  10. Centos下部署Flask

    尝试在Centos6.5下部署Flask应用并成功,记录一下步骤,参数为什么这样配置还需要再研究uwsgi和Nginx才能回答. Python版本升级2.7 测试机器centos6.5默认自带的pyt ...