1.安装
系统:centos6.5
方式1:curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
yum install -y gitlab-ce
如果方式1在curl步骤执行不成功,采用方法2
方式2:/etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
2.配置
修改配置文件/etc/gitlab/gitlab.rb后需要reconfigure
external_url 'http://local.gitlab.com' 配置访问gitlab的url
nginx['enable'] = true;表示使用内置的
nginx['listen_port'] = 8085
nginx增加一个server配置模块
# gitlab socket 文件地址
upstream gitlab {
# 7.x 版本在此位置
# server unix:/var/opt/gitlab/gitlab-rails/tmp/sockets/gitlab.socket;
# 8.0 位置
#server unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;//网上这个是错的,当git clone 的时候会包500
server 127.0.0.1:8085;//nginx方向代理到gitlab的内置nginx监听端口上,也就是上面配置的8085,不能代理到gitlab.socket
}
server {
listen *:80;
server_name local.gitlab.com; # 请修改为你的域名
server_tokens off; # don't show the version number, a security best practice
root /opt/gitlab/embedded/service/gitlab-rails/public;
# Increase this if you want to upload large attachments
# Or if you want to accept large git objects over http
client_max_body_size 250m;
# individual nginx logs for this gitlab vhost
access_log /var/log/gitlab/nginx/gitlab_access.log;
error_log /var/log/gitlab/nginx/gitlab_error.log;
location / {
# serve static files from defined root folder;.
# @gitlab is a named location for the upstream fallback, see below
try_files $uri $uri/index.html $uri.html @gitlab;
}
# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
# If you use https make sure you disable gzip compression
# to be safe against BREACH attack
proxy_read_timeout 300; # Some requests take more than 30 seconds.
proxy_connect_timeout 300; # Some requests take more than 30 seconds.
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_pass http://gitlab;
}
# Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
# WARNING: If you are using relative urls do remove the block below
# See config/application.rb under "Relative url support" for the list of
# other files that need to be changed for relative url support
location ~ ^/(assets)/ {
root /opt/gitlab/embedded/service/gitlab-rails/public;
# gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
error_page 502 /502.html;
}
修改/etc/gitlab/gitlab.rb后需要重载gitlab配置:
gitlab-ctl reconfigure
重载nginx:service nginx restart
访问时若出现502,则是权限配置问题,原本是 nginx 用户无法访问gitlab用户的 socket 文件,用户权限配置,
chmod -R o+x /var/opt/gitlab/gitlab-rails
周期分析包含以下阶段:
问题: 它指定了多少时间来解决问题。
计划: 它规定了将第一次提交到分支和前一阶段采取的行动之间的时间。
代码: 它指定将第一次提交到分支和为该提交创建合并请求之间的时间。
测试: 它指定了多少时间需要GitLab CI / CD来测试代码。
评论: 它指定检查合并请求所花费的时间。
分期: 它定义了在合并和部署到生产之间花费的时间。
生产: 指定完成整个过程所需的时间,从创建问题到部署代码到生产。
---------安装 GitLab Runner --------------
源码:https://gitlab.com/gitlab-org/gitlab-runner
https://docs.gitlab.com/runner/install/linux-manually.html
/usr/local/bin/gitlab-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user gitlab-runner
查看gitlab版本:
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
查看gitlab所有服务状态:sudo gitlab-ctl status
sudo gitlab-ctl tail postgresql
初次配置服务:sudo gitlab-ctl reconfigure
启动服务:sudo gitlab-ctl start
停止服务:sudo gitlab-ctl stop
重启服务:sudo gitlab-ctl restart
检查服务的日志信息:sudo gitlab-ctl tail
测试ssh连通性:ssh -T -p2222 git@local.gitlab.com
----------------
启动gitlab-runner:/usr/local/bin/gitlab-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user gitlab-runner
gitlab-runner register \
--non-interactive \
--url "https://gitlab.com/" \
--registration-token "PROJECT_REGISTRATION_TOKEN" \
--executor "docker" \
--docker-image alpine:3 \
--description "docker-runner" \
--tag-list "docker,aws" \
--run-untagged \
--locked="false" \
gitlab-runner unregister --name test-runner
gitlab-runner verify (查看能连通gitlab的runner,带上--delete会删除不能连通的runner)
gitlab-runner list
----------gitlab-runner问题解决-
WARNING: Checking for jobs... failed runner=82191bf0 status=couldn't execute POST against
解决方法:nginx没起来,80端口没监听,把nginx启动