Jenkins+Gitlab+Git

(二)Git+Gitlab连接使用

2020-02-27  本文已影响0人  小二哥很二

前置条件:git客户端windows,gitlab服务端搭建,centos7系统

一、Git客户端安装,创建本地仓库

>>cd ~/.ssh
>>ls
id_rsa  id_rsa.pub  known_hosts

二、Gitlab远程服务端搭建

[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1

[root@localhost gitlab]# whereis gitlab
gitlab: /etc/gitlab
[root@localhost gitlab]# 

2)cd到该目录下,ls查看目录下文件

[root@localhost gitlab]# ls
gitlab.rb  gitlab-secrets.json  trusted-certs

3)编辑gitlab.rb文件[root@localhost gitlab]# vi gitlab.rb

image.png

4)配置邮箱和关闭普罗米修斯prometheus

第一步:在gitlab.rb文件里查找:/Email Settings,修改以下三行,取消注释
### Email Settings
 gitlab_rails['gitlab_email_enabled'] = true
 gitlab_rails['gitlab_email_from'] = 'xxxxxx@qq.com'     //填写自己的邮箱
 gitlab_rails['gitlab_email_display_name'] = 'xiaoer'
# gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com'
# gitlab_rails['gitlab_email_subject_suffix'] = ''
# gitlab_rails['gitlab_email_smime_enabled'] = false
# gitlab_rails['gitlab_email_smime_key_file'] = '/etc/gitlab/ssl/gitlab_smime.key'
# gitlab_rails['gitlab_email_smime_cert_file'] = '/etc/gitlab/ssl/gitlab_smime.crt

第二步:修改邮箱服务smtp.qq.com,查找命令:/stmp,修改成如下信息
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxxxxxx@qq.com"     /填写自己的邮箱
gitlab_rails['smtp_password'] = "xxxxkkkk"      //此密码为授权码,在qq邮箱设置里生成
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true

第三步:关闭prometheus,具体是做什么的,小二暂时不知道,查找,n键翻页,将第一行注释去掉,并改成false
prometheus['enable'] = false
# prometheus['monitor_kubernetes'] = true
# prometheus['username'] = 'gitlab-prometheus'
# prometheus['group'] = 'gitlab-prometheus'
# prometheus['uid'] = nil

三、配置远程仓库Gitlab的SSH key,连接本地仓库

$ git pull origin master                                                           
warning: no common commits                                                         
remote: Enumerating objects: 3, done.                                             
remote: Counting objects: 100% (3/3), done.       #==>有进度展示                                  
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0                       
Unpacking objects: 100% (3/3), done.                                               
From http://192.168.1.103:82/test1/jenkins                                          
* branch            master     -> FETCH_HEAD                                       
* [new branch]      master     -> origin/master                                   
fatal: refusing to merge unrelated histories 
$ git branch -va                                                                   
* master                f819cad creat the first py       #本地的
remotes/origin/master cd45b60 Initial commit             #远程的

直接merge会报错:
$ git merge origin/master                                                         
fatal: refusing to merge unrelated histories 

使用git merge -h命令查看帮助,然后使用--allow-unrelated-histories命令
$ git merge --allow-unrelated-histories origin/master                              
Merge made by the 'recursive' strategy.                                             
README.md | 3 +++                                                                  
1 file changed, 3 insertions(+)                                                    
create mode 100644 README.md 

然后就可以了,也可以使用gitk --all查看分支树,我看不懂

四、补充:域名解析

上一篇下一篇

猜你喜欢

热点阅读