me小怪兽

导航

安装gitlab

 

添加源

[root@zabbix_server yum.repos.d]# cat gitlab.repo 
[gitlab]
name=gitlab
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
enabled=1
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

 

 [root@zabbix_server yum.repos.d]# yum -y install gitlab-ce-14.9.5

 

[root@zabbix_server ~]# vim /etc/gitlab/gitlab.rb

 关闭以下参数

prometheus['enable'] = false
prometheus['monitor_kubernetes'] = false

prometheus_monitoring['enable'] = false

alertmanager['enable'] = false

node_exporter['enable'] = false

redis_exporter['enable'] = false

postgres_exporter['enable'] = false

gitlab_exporter['enable'] = false

grafana['enable'] = false

 

修改完主配置文件后,使用gitlab-ctl reconfifigure重新配置gitlab使配置生效
[root@zabbix_server ~]# gitlab-ctl reconfigure
Running handlers:
Running handlers complete
Chef Infra Client finished, 602/1616 resources updated in 02 minutes 46 seconds

Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.

NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

gitlab Reconfigured!

[root@zabbix_server ~]# gitlab-ctl status

run: gitaly: (pid 3673) 136s; run: log: (pid 2758) 274s
run: gitlab-kas: (pid 3617) 139s; run: log: (pid 3017) 262s
run: gitlab-workhorse: (pid 3631) 139s; run: log: (pid 3145) 219s
run: logrotate: (pid 2687) 288s; run: log: (pid 2715) 285s
run: nginx: (pid 3174) 214s; run: log: (pid 3203) 211s
run: postgresql: (pid 2880) 269s; run: log: (pid 2959) 266s
run: puma: (pid 3082) 232s; run: log: (pid 3089) 231s
run: redis: (pid 2718) 281s; run: log: (pid 2726) 280s
run: sidekiq: (pid 3100) 226s; run: log: (pid 3108) 225s
登录GitLab
浏览器访问GitLab服务器地址:http://IP
默认用户名:root
root初始密码所在文件:/etc/gitlab/initial_root_password

 

通过个人资料中心修改root密码

 

设置密码后会跳转到登录页面重新登录。

修改页面语言 

 

定制Logo及登录页面,可以自定义你希望展示的一些内容。点击左上角的
菜单(Menu)→Admin→设置→外观 

 

 

关闭注册功能

由于我们Gitlab系统是私有仓库,一般用户都是由管理员创建和分派的,
所以我们需要关闭注册。
点击左上角 菜单(Menu)→管理(Admin)→通用 找到注册限制取消掉
注册功能。

 

将勾选取消,点击 保存更改(Save changes)
 

新建群组

群组就是把相关的项目和用户放在一起,进行统一的权限管理,点击 菜单
(Menu)→管理(Admin)点击 新建群组
 

 

在可见性级别处我们选择私有,这样只有经过授权的用户才可以看到该组
内的项目,其他用户无法查看。
配置完相关信息点击最下方的创建群组。 
  

创建仓库

我们在GitLab创建一个项目仓库用于存放项目代码,菜单(Menu)→管
理(Admin)→新建项目

 

设置SSH Key 

请注意最上方的提示,点击提示中的添加SSH密钥 来设置访问方式 

 

将本机~/.ssh/id_rsa.pub公钥文件内容复制到GItLab的SSH密钥处。
[root@zabbix_server .ssh]# cat /root/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDT44jSgVeg6yX0lCN8uylZhTGGPyWMX97SEJHGMEW1HR3mgOZAHcZAINRw1AEOC0kp52JRUQ0oTT7vTb03JvT/alVaWb2jzQGcpvEAArRT7+6WKwxX+gSdGVmNzQdvFCb7TFxJig1joQGKEIGlD3ec2Ps4BxWwQ+hPkXXK8NyAkAsFP1KUDb2z+foeM/5chyM0TKzmIpq1f/yLIEKJ0Eu709TvBX6hLoeZJACkF9uru/c0agqa5dZjYaOYofOWv1Ji3rtx/rUF+00xaCQqhU2zq4NHHyppTLiSrfoKMi58y0VBHTsK9vet7v6Of1+3DOQ+XT2F2X0yraKk26jPg51v root@zabbix_server

 

 

 

粘贴完成后其他默认即可,点击添加密钥 后再次回到项目中 

推送代码

 

将代码推送到choujiang项目中
安装Git工具
# yum -y install git 
配置Git的用户与邮箱 

# git config --global user.name "Administrator"
# git config --global user.email "admin@example.com"

初始化目录为Git版本库
# git init
项目推送到仓库的流程
# git add .
# git commit -m '第一次提交'
添加远程仓库

# git remote add origin http://192.168.61.139/root/pord.git

推送项目到远程仓库 
[root@local gitlab_html]# git push -u origin --all
Username for 'http://192.168.61.139': root
Password for 'http://root@192.168.61.139': 
Counting objects: 1641, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1581/1581), done.
Writing objects: 100% (1641/1641), 18.38 MiB | 7.69 MiB/s, done.
Total 1641 (delta 476), reused 0 (delta 0)
remote: Resolving deltas: 100% (476/476), done.
remote: 
remote: To create a merge request for master, visit:
remote:   http://192.168.61.139/root/pord/-/merge_requests/new?merge_request%5Bsource_branch%5D=master
remote: 
To http://192.168.61.139/root/pord.git
 * [new branch]      master -> master
分支 master 设置为跟踪来自 origin 的远程分支 master。

 

 

持续集成 Jenkins
清华大学下载Jenkins稳定版地址:
https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/ 
Jenkins需要依赖Java环境,需要提前安装jdk环境(fontconfifig软件提供
Jenkins web界面字体) 
yum install fontconfig java-11-openjdk -y
[root@jenkins local]# java -version
openjdk version "11.0.19" 2023-04-18 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.19.0.7-1.el7_9) (build 11.0.19+7-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.19.0.7-1.el7_9) (build 11.0.19+7-LTS, mixed mode, sharing)
安装Jenkins
[root@jenkins local]# rpm -ivh jenkins-2.361.4-1.1.noarch.rpm 
警告:jenkins-2.361.4-1.1.noarch.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 45f2c3d5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:jenkins-2.361.4-1.1              ################################# [100%]
[root@jenkins local]# systemctl restart jenkins.service 
[root@jenkins local]# systemctl status jenkins.service 
● jenkins.service - Jenkins Continuous Integration Server
   Loaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; vendor preset: disabled
   Active: active (running) since 二 2023-07-04 17:18:42 CST; 40s ago
 Main PID: 14811 (java)
   CGroup: /system.slice/jenkins.service
           └─14811 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --

7月 04 17:17:35 jenkins jenkins[14811]: Jenkins initial setup is required. An admin user has 
7月 04 17:17:35 jenkins jenkins[14811]: Please use the following password to proceed to insta
7月 04 17:17:35 jenkins jenkins[14811]: 818018da58314584947f913991070dd5
7月 04 17:17:35 jenkins jenkins[14811]: This may also be found at: /var/lib/jenkins/secrets/i
7月 04 17:17:35 jenkins jenkins[14811]: *****************************************************
7月 04 17:17:35 jenkins jenkins[14811]: *****************************************************
7月 04 17:17:35 jenkins jenkins[14811]: *****************************************************
7月 04 17:18:42 jenkins jenkins[14811]: 2023-07-04 09:18:42.370+0000 [id=31]        INFO     
7月 04 17:18:42 jenkins jenkins[14811]: 2023-07-04 09:18:42.389+0000 [id=22]        INFO     
7月 04 17:18:42 jenkins systemd[1]: Started Jenkins Continuous Integration Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@jenkins local]# systemctl enable jenkins.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/jenkins.service to /usr/lib/
[root@jenkins local]# 

访问jenkins

ip+8080

 

[root@jenkins local]# cat /var/lib/jenkins/secrets/initialAdminPassword
818018da58314584947f913991070dd5
[root@jenkins local]# 

 等待安装

 

实例配置

 

posted on 2023-07-03 19:05  me小怪兽  阅读(76)  评论(0编辑  收藏  举报