Gitlab-CE

官方快速入门文档
.gitlab-ci.yml文件官方示例
.gitlab-ci.yml完整说明

语法验证,可以在项目对应的目录/gitlab-org/project-123/-/ci/lint 进行验证 查看搭建的gitlab系统版本/api/v4/version,返回类似{"version":"11.11.3","revision":"e3eeb779d72"}的内容。

配置完成后,需要对应的Gitlab Runner配合执行.gitlab-ci.yml文件中对应的任务。runner 官方文档

安装Gitlab CE

安装一个CE版本,自己实践一下——

#依赖
sudo apt-get install -y curl openssh-server ca-certificates
#邮件
sudo apt-get install -y postfix
#添加源
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
#安装
sudo EXTERNAL_URL="http://your.domain:port" apt-get install gitlab-ce


Reading state information... Done
The following packages were automatically installed and are no longer required:
  libopts25 sntp
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  gitlab-ce
0 upgraded, 1 newly installed, 0 to remove and 50 not upgraded.
Need to get 742 MB of archives.
After this operation, 1,927 MB of additional disk space will be used.

按照固定带宽在下载,看起来要慢慢等了。

502 Whoops, GitLab is taking too much time to respond

看起来我的小破机器跑不起来gitlab的。GitLab requires at least 2GB RAM + 2GB swap memory


手动安装,下载deb包之后,执行sudo EXTERNAL_URL="http://your.domain:port" dpkg -i gitlab-ce_12.6.2-ce.0_amd64.deb即可。

manual install


#Turn off all swap processes
sudo swapoff -a

#Resize the swap
sudo dd if=/dev/zero of=/swapfile bs=1G count=8
#if = input file
#of = output file
#bs = block size
#count = multiplier of blocks

#Make the file usable as swap
sudo mkswap /swapfile

#Activate the swap file
sudo swapon /swapfile
#Check the amount of swap available
grep SwapTotal /proc/meminfo

手动增大SWAP区域之后,至少启动起来了

修改主页

安装完成后的配置

# Start all GitLab components
sudo gitlab-ctl start

# Stop all GitLab components
sudo gitlab-ctl stop

# Restart all GitLab components
sudo gitlab-ctl restart

# check log 
sudo gitlab-ctl tail

安装gitlab runner

官方安装文档,在已经启动的gitlab实例目录/admin/runners下可以看到安装步骤,需要管理员权限

Set up a shared Runner manually

  1. Install GitLab Runner
  2. Specify the following URL during the Runner setup: http://xxx.com:port/ 
  3. Use the following registration token during setup: token-value 
  4. Start the Runner!

官方Runner文档——

GitLab Runner should be the same version as GitLab. Older runners may still work with newer GitLab versions, and vice versa. However, features may be not available or work properly if a version difference exists.

Go语言编写,二进制发布,多平台支持。

历史版本下载页面,根据 官方仓库tag列表的不同分支,选择对应的版本——

例如,v12.6版本,分支对应为v12.6.0,则二进制版本下载地址为https://s3.amazonaws.com/gitlab-runner-downloads/**v12.6.0**/binaries/gitlab-runner-linux-386

  1. 添加可执行权限:sudo chmod +x gitlab-runner
  2. 创建执行用户:sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
  3. 安装为服务:
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start
  1. 注册runner,即将runner与gitlab绑定。Register a runner

建议是Gitlab和Gitlab Runner分离,但不考虑安全、性能的情况下,同时在一台机器上跑没有问题。参考 CI runner on same server of GitLab?,或者 Setting up GitLab CI on server with GitLab already installed

 
comments powered by Disqus