Gitlab代码托管服务器的安装

分享
开发者 2024-10-7 18:55:22 48 0 来自 中国
一、Gitlab 简介

官网:https://about.gitlab.com/
GitLab 是一个用于堆栈管理体系的开源项目,使用Git作为代码管理工具,并在此底子上搭建起来的web服务。
GitLab和GitHub一样属于第三方基于Git开辟的作品,免费且开源(基于MIT协议),与Github雷同,可以注册用户,恣意提交你的代码,添加SSHKey等等。差异的是,GitLab是可以摆设到本身的服务器上,数据库等一切信息都把握在本技艺上,得当团队内部协作开辟,你总不大概把团队内部的智慧总放在别人的服务器上吧?简单来说可把GitLab看作个人版的GitHub。
二、Gitlab的安装



    • 安装干系依靠:

yum -y install policycoreutils openssh-server openssh-clients postfix


    • 启动ssh服务&设置为开机启动

systemctl enable sshd && sudo systemctl start sshd


    • 设置postfix开机自启,并启动,postfix支持gitlab发信功能

systemctl enable postfix && systemctl start postfix


    • 开放ssh以及http服务,然后重新加载防火墙列表

firewall-cmd --add-service=ssh --permanentfirewall-cmd --add-service=http --permanentfirewall-cmd --reload假如关闭防火墙就不须要做以上设置


    • 下载gitlab包,而且安装
      gitlab下载所在:https://packages.gitlab.com/gitlab/gitlab-ce

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm安装:
rpm -i gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm


    • 修改gitlab设置

vi /etc/gitlab/gitlab.rb# 修改Gitlab访问所在和端口,默以为80,我们改为82external_url 'http://192.168.18.100:82'nginx['listen_port'] = 82


    • 重载设置以及重新启动Gitlab(须要耐心等待一段时间):

sudo gitlab-ctl reconfiguresudo gitlab-ctl restart


    • 把端口添加到防火墙

firewall-cmd --zone=public --add-port=82/tcp --permanentfirewall-cmd --reload开机自启动:
systemctl enable gitlab-runsvdir.service启动乐成后访问http://192.168.18.100:82,看到以下管理员root暗码的页面,修改暗码后,重新登录即可。

1.png 三、Gitlab创建组、创建用户、创建项目

3.1 创建组

● 使用管理员root创建组,一个组内里可以有多个项目,可以将开辟添加组内里举行设置权限,差异的组就是公司差异的开辟项目大概服务模块,差异的组添加差异的开辟即可实现对开辟设置权限的管理。
2.png 3.2 创建用户

● 创建用户的时候,可以选择Regular(普通用户:只能访问属于他的组和项目)或Admin(可以访问全部的组和项目)范例。
● 创建完用户,立刻修改暗码:

6.png 7.png
这里的用户名和暗码须要记着,用于背面的jenkins登录拉取代码。
3.3 将用户添加到组中

8.png 10.png Gitlab用户在组内里有5种差异的权限。
● Guest:可以创建isssue,发表品评,不能读写版本库。
● Reporter:可以clone代码,不能提交,比如QA、PM可以赋予这个权限。
● Developer:可以clone代码、开辟、提交、push,比如普通开辟可以赋予这个权限。
● Maintainer:可以创建项目、添加tag、掩护分支、添加项目成员、编辑项目,比如核心开辟可以赋予这个权限。
● Owner:可以设置项目访问权限、删除项目、迁移项目、管理构成员,比如开辟组组长可以赋予这个权限。
3.4 在用户组中添加项目

● 可以用root管理员在用户组中添加项目,也可以用刚才创建的账户登录到Gitlab中添加项目(须要重设暗码,略)。

13.png 14.png 16.png 四、源码上传到Gitlab堆栈

4.1 新建项目

17.png 19.png 4.2 开启版本控制

21.png

  • 出现如下框 选择Git


4.3 新建一个.gitignore file (Git)



  • 勾掉一些不须要的

    24.png
  • 出现如下框


  • 假如不知道.gitignore file (Git) 要勾选掉哪些  就直接复制如下代码到.gitignore 里就好
# Created by .ignore support plugin (hsz.mobi)### Maven templatetarget/ ### JetBrains template# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion *.iml ## Directory-based project format:.idea/# if you remove the above rule, at least ignore the following: # IntelliJ/out//build/ # mpeltonen/sbt-idea plugin.idea_modules/ ### OSX template.DS_Store.AppleDouble.LSOverride # Icon must end with two \rIcon # Thumbnails._* # Files that might appear in the root of a volume.DocumentRevisions-V100.fseventsd.Spotlight-V100.TemporaryItems.Trashes.VolumeIcon.icns # Directories potentially created on remote AFP share.AppleDB.AppleDesktopNetwork Trash FolderTemporary Items.apdisk### Windows template# Windows image file cachesThumbs.dbehthumbs.db # Folder config fileDesktop.ini # Recycle Bin used on file shares$RECYCLE.BIN/ # Windows Installer files*.cab*.msi*.msm*.msp # Windows shortcuts*.lnk ~* ### Eclipse template*.pydevproject.metadata.gradlebin/tmp/*.tmp*.bak*.swp*~.niblocal.properties.settings/.loadpath # Eclipse Core.project # External tool builders.externalToolBuilders/ # Locally stored "Eclipse launch configurations"*.launch # CDT-specific.cproject # JDT-specific (Eclipse Java Development Tools).classpath # Java annotation processor (APT).factorypath # PDT-specific.buildpath # sbteclipse plugin.target # TeXlipse plugin.texlipse #.gitignore.checkstyletest-output4.4 提交接码到本地堆栈


  • 项目add后  新建的类包罗.gitignore会由赤色变成绿色

    26.png
  • 项目里添加类与代码后  commit ...(到本地库)

    27.png
  • 如下

    28.png
4.5 推送到Gitlab项目堆栈中

30.png 参考:
https://blog.csdn.net/weixin_41979002/article/details/121686628
https://www.shuzhiduo.com/A/8Bz8eg7OJx/
https://www.yii666.com/blog/319403.html
您需要登录后才可以回帖 登录 | 立即注册

Powered by CangBaoKu v1.0 小黑屋藏宝库It社区( 冀ICP备14008649号 )

GMT+8, 2024-10-18 16:47, Processed in 0.183691 second(s), 35 queries.© 2003-2025 cbk Team.

快速回复 返回顶部 返回列表