Omnibus Gitlab + Runner 配置

来源:互联网 发布:休闲鞋女淘宝 编辑:程序博客网 时间:2024/06/08 10:00

本文以最小化安装为前题 (最快速安装/最少行指令/1台服务器)


安装Gitlab CE

  1. 前往https://about.gitlab.com/downloads/,并选择自己的操作系统,我自己使用的是CentOS 6,如果不是CentOS的话按照官网上的英文教程操作即可,以下代码摘取自CentOS6的安装教程。
  2. 安装需要的dependencies(postfix是发送邮件的程序,Gitlab需要发送邮件来验证注册用户的邮箱是否合法,我使用第三方SMTP服务器进行发送,你可以自行决定是否要使用postfix)
    sudo yum install curl openssh-server openssh-clients postfix croniesudo service postfix startsudo chkconfig postfix onsudo lokkit -s http -s ssh

  3. 增加gitlab source并且安装
    curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bashsudo yum install gitlab-ce

  4. 安装完成之后运行gitlab设置程序
    sudo gitlab-ctl reconfigure

  5. 设置完成之后浏览到http://localhost,设置初始密码并登入,预设管理员帐号是 root
*若在国内因为伟大的GFW而无法安装Gitlab,查看这篇文章的作法https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/

安装Gitlab Runner

  1. 先安装Docker (Docker是一种虚拟机,Runner在执行test的时候会以一台乾净的机器的形式执行测试)
    curl -sSL https://get.docker.com/ | sh

  2. 将runner添加到安装source里(自行选择对应的系统)
    # For Debian/Ubuntucurl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.deb.sh | sudo bash# For CentOScurl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash

  3. 安装runner
    # For Debian/Ubuntusudo apt-get install gitlab-ci-multi-runner# For CentOSsudo yum install gitlab-ci-multi-runner

  4. 执行runner configuration
    sudo gitlab-ci-multi-runner register
  5. 参考如下回答
    Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci )自己gitlab的域名,后面加/ciPlease enter the gitlab-ci token for this runner用管理员帐号登入自己的gitlab -> Admin Area -> Settings -> Runner -> 并且复制该页面的registration token到此Please enter the gitlab-ci description for this runner给这个runner一个名字,随便写,我给的是Local Shared RunnerINFO[0034] fcf5c619 Registering runner... succeededPlease enter the executor: shell, docker, docker-ssh, ssh?dockerPlease enter the Docker image (eg. ruby:2.1):php5.6INFO[0037] Runner registered successfully. Feel free to start it, but if it'srunning already the config should be automatically reloaded!

  6. 最后确保docker有在运行
    sudo service docker start

0 0
原创粉丝点击