Gitlab介绍
GitLab是一个基于Git的开源项目管理工具,它集成了版本控制、代码审查、持续集成(CI)/持续部署(CD)、自动化测试等多种功能,是一个完整的DevOps平台。以下是对GitLab的详细介绍:
一、主要特点和功能
- 版本控制系统:GitLab的核心是基于Git的版本控制系统,支持代码的版本管理、分支管理、合并操作等。
- 代码审查:提供代码审查功能,帮助团队提高代码质量,确保代码符合项目标准。
- 持续集成/持续部署(CI/CD):通过内置的CI/CD工具,实现自动化构建、测试和部署,提高开发效率和产品质量。
- 问题跟踪:内置的问题跟踪系统,帮助团队管理和跟踪项目中的问题和任务。
- Wiki:提供项目相关的文档管理功能,方便团队成员共享知识和信息。
- 安全性:提供多种安全功能,如分支权限、合并请求审批流程等,保护代码的安全和项目的稳定。
- 可视化界面:提供一个直观易用的图形用户界面,使得项目管理更加便捷。
使用概况
以下我配置访问端口为8888,所有浏览器:http://127.0.0.1:8888访问
网站登录管理的用户名和密码进入gitlab的命令中配置:sudo gitlab-rails console
配置可以正常登录后,就都是在浏览器里面操作了
在Ubuntu上配置和使用GitLab,你可以按照以下步骤进行操作:
- 更新系统软件包列表:
sudo apt-get update
- 安装必要的依赖项:
sudo apt-get install -y ca-certificates curl openssh-server
- 添加GitLab的APT仓库并安装GitLab包:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
sudo EXTERNAL_URL="http://your_domain_or_ip" apt-get install gitlab-ee
- 配置防火墙以允许HTTP和SSH流量通过:
sudo ufw allow http sudo ufw allow ssh sudo ufw enable sudo ufw status
- 启动并配置GitLab服务:
sudo gitlab-ctl reconfigure
安装后使用
- 访问GitLab Web界面: 在浏览器中输入http://your_domain_or_ip,你应该能够看到GitLab的登录页面。使用默认的管理员账号(用户名:root,密码:5iveL!fe)登录。
- 更改默认管理员密码: 登录后,导航到"Admin Area" -> "Sign-in as root",然后点击"Reset the admin password"链接来设置新密码。
- 配置GitLab
sudo nano /etc/gitlab/gitlab.rb
# 默认用户名root,我这里中文和密码未生效,密码需要在后面命令中更改,有效参数为external_url
gitlab_rails['gitlab_default_language'] = 'zh-CN'
gitlab_rails['initial_root_password'] = 'Huang123'
external_url = 'http://127.0.0.1:8888'
#gitlab 监听的端口
nginx['listen_port'] = 8888
# 其他配置,启用电子邮箱
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.example.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "your-email-password"
gitlab_rails['smtp_domain'] = "example.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
# 启用用户注册
gitlab_rails['gitlab_signup_enabled'] = false
# 启用身份验证
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS' # remember to close this block with 'EOS' on next line
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: 'ldap.example.com'
port: 389
uid: 'sAMAccountName'
method: 'plain' # "tls" or "ssl" or "plain"
bind_dn: 'CN=admin,DC=example,DC=com'
password: 'password'
active_directory: true
allow_username_or_email_login: false
block_auto_created_users: false
base: 'ou=users,dc=example,dc=com'
user_filter: ''
EOS
- 启动GitLab
# 启动服务
sudo gitlab-ctl start
# 启动并更新配置
sudo gitlab-ctl reconfigure
# 重启
sudo gitlab-ctl restart
- 调试,更改登录密码
# 进入gitlab命令调试
sudo gitlab-rails console
# 查看用户名和密码
User.all.each do |user|
puts "Username: #{user.username}, Password: #{user.password}"
end
# 更改密码,使用邮箱或用户名登录,更改密码时不能太简单,复制可能出现错误
user = User.find_by(email: '[email protected]')
user = User.find_by(username: 'your_username')
user.password = 'newpassword'
user.password_confirmation = 'newpassword'
user.save!
- 更改语言为简体中文
- 常用命令(gitlab-ctl)
如:gitlab-ctl stop停止
cleanse
Delete *all* gitlab data, and start from scratch.
help
Print this help message.
reconfigure
Reconfigure the application.
show-config
Show the configuration that would be generated by reconfigure.
uninstall
Kill all processes and uninstall the process supervisor (data will be preserved).
Service Management Commands:
graceful-kill
Attempt a graceful stop, then SIGKILL the entire process group.
hup
Send the services a HUP.
int
Send the services an INT.
kill
Send the services a KILL.
once
Start the services if they are down. Do not restart them if they stop.
restart
Stop the services if they are running, then start them again.
restart-except
Restart all services except: service_name ...
service-list
List all the services (enabled services appear with a *.)
start
Start services if they are down, and restart them if they stop.
status
Show the status of all the services.
stop
Stop the services, and do not restart them.
tail
Watch the service logs of all enabled services.
term
Send the services a TERM.
usr1
Send the services a USR1.
usr2
Send the services a USR2.
Gitlab相关的四种工具:Jenkins、SVN、BitBucket、Git、gitea(轻量级全功能)
除了BitBucket其他都用过,我搜Git的使用教程附加在后面。
gitea可以配置提交代码后通过webhook自动触发Jenkins构建版本
标签:GitLab,代码,gitlab,smtp,rails,services,sudo,安装 From: https://blog.csdn.net/qq_17242837/article/details/143355906