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

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

安装Gitlab CE


sudo apt-get install -y curl openssh-server ca-certificates
sudo apt-get install -y postfix
curl -sS | 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:
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




# 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


Set up a shared Runner manually

  1. Install GitLab Runner
  2. Specify the following URL during the Runner setup: 
  3. Use the following registration token during setup: token-value 
  4. Start the 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.


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


  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