GitLab代码仓管理安装配置使用

Gitlab介绍

GitLab是一个基于Git的开源项目管理工具,它集成了版本控制、代码审查、持续集成(CI)/持续部署(CD)、自动化测试等多种功能,是一个完整的DevOps平台。以下是对GitLab的详细介绍:

一、主要特点和功能

  1. 版本控制系统:GitLab的核心是基于Git的版本控制系统,支持代码的版本管理、分支管理、合并操作等。
  2. 代码审查:提供代码审查功能,帮助团队提高代码质量,确保代码符合项目标准。
  3. 持续集成/持续部署(CI/CD):通过内置的CI/CD工具,实现自动化构建、测试和部署,提高开发效率和产品质量。
  4. 问题跟踪:内置的问题跟踪系统,帮助团队管理和跟踪项目中的问题和任务。
  5. Wiki:提供项目相关的文档管理功能,方便团队成员共享知识和信息。
  6. 安全性:提供多种安全功能,如分支权限、合并请求审批流程等,保护代码的安全和项目的稳定。
  7. 可视化界面:提供一个直观易用的图形用户界面,使得项目管理更加便捷。

使用概况

以下我配置访问端口为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

安装后使用

  1. 访问GitLab Web界面: 在浏览器中输入http://your_domain_or_ip,你应该能够看到GitLab的登录页面。使用默认的管理员账号(用户名:root,密码:5iveL!fe)登录。

  2. 更改默认管理员密码: 登录后,导航到"Admin Area" -> "Sign-in as root",然后点击"Reset the admin password"链接来设置新密码。

  3. 配置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'] = "your-email@example.com"
    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: 'admin@example.com')
    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构建版本

相关推荐
物联网软硬件开发-轨物科技21 分钟前
【技术白皮书】光伏清检一体化机器人系统解决方案技术白皮书
大数据·运维·网络·人工智能·机器人
Escalating_xu24 分钟前
【Linux 网络编程】TCP 跨平台实战:用 Windows 客户端访问 Linux 服务器
linux·服务器·网络
发量惊人的中年网工27 分钟前
分公司访问总部ERP慢怎么办?SD-WAN组网的排查与验收要点
服务器·开发语言·php
海宇数据30 分钟前
零信任架构实战:基于海宇网上踪迹欺诈行为识别构建自动化信贷资信评估网关
运维·人工智能·架构·自动化
翼龙云_cloud1 小时前
亚马逊云服务器服务代理商:Bedrock 实践经验 Serverless 架构下的 AI 自动化落地
服务器·架构·serverless·云计算·aws
忆挽篱笙歌1 小时前
环境变量,本地变量
linux·运维·服务器
Demons_kirit2 小时前
CTFHub 信息泄露通关笔记:Git泄露 Log - 教程
笔记·git·网络安全
码间留白2 小时前
手把手把 GitHub 推上阿里云 ECS:Actions CI/CD 全链路避坑实录(折腾好几天,到 2 分钟见绿)
运维·阿里云·ci/cd·docker·devops·github actions
吹什么轩3 小时前
linux系统复习:僵尸进程与孤儿进程
linux·运维·php
张宇Joaquin4 小时前
AMD uProf 工具采集微架构特征使用介绍
服务器