git工具的使用 、gitlab 服务器的搭建、Jenkins服务的搭建

1.git工具的使用

git工具的安装:

[root@foundation52 ~]# mkdir demo
[root@foundation52 ~]# cd demo/
[root@foundation52 demo]# ls
[root@foundation52 demo]# git init
bash: git: command not found...
##安装git工具
[root@foundation52 demo]# yum whatprovides git
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
git-1.8.3.1-6.el7_2.1.x86_64 : Fast Version Control System
Repo        : source7.3
[root@foundation52 demo]# yum install git-1.8.3.1-6.el7_2.1.x86_64 -y

初始化git本地仓库:

当执行完git init 后,当前目录下会自动生成.git隐藏文件夹,该隐藏文件夹就是git版本库
##初始化
[root@foundation52 demo]# git init
Initialized empty Git repository in /root/demo/.git/
[root@foundation52 demo]# ls
[root@foundation52 demo]# l.
.  ..  .git
[root@foundation52 demo]# cd .git/
[root@foundation52 .git]# ls
branches  config  description  HEAD  hooks  info  objects  refs
[root@foundation52 .git]# cd ..
[root@foundation52 demo]# ls

将文件放到Git仓库中:

## > 表示 导入
[root@foundation52 demo]# echo westos > readme.md
##查看“工作区”和“暂存区”的状态
[root@foundation52 demo]# git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   readme.md
nothing added to commit but untracked files present (use "git add" to track)
##查看简略版状态  ?? 表示还未对文件做任何操作
[root@foundation52 demo]# git status -s
?? readme.md
##1.把文件从“工作区”添加到“暂存区
[root@foundation52 demo]# git add readme.md 
[root@foundation52 demo]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#   new file:   readme.md
#
## A表示已经添加成功
[root@foundation52 demo]# git status -s
A  readme.md
## 2.把文件从“暂存区”提交到“版本区”; commit 表示提交
## -m 表示自己写的一些注释” 我们直接添加注释,这样不会弹出一个记事本去添加注释 
[root@foundation52 demo]# git commit -m "add readme.md"
[master (root-commit) bd67b19] add readme.md
 Committer: root <root@foundation52.ilt.example.com>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
 create mode 100644 readme.md
[root@foundation52 demo]# git status -s

用户信息默认记录在.gitconfig 文件中:

[root@foundation52 demo]# git config --global user.name hym
[root@foundation52 demo]# git config --global user.email "865700373@qq.com"
[root@foundation52 demo]# cd
[root@foundation52 ~]# l.
.              .cshrc      .local            .xauth0p1led  .xauthBIEBeQ
..             .dbus       .mysql.3800       .xauth1pJSgq  .xauthCY9BEd
.bash_history  .docker     .mysql_history    .xauth4kIUb1  .xauthELWOKK
.bash_logout   .gitconfig  .PyCharmCE2016.3  .xauth5ap5kx  .xauthXu2Sg4
.bash_profile  .gnome      .rnd              .xauth5p0Ada
.bashrc        .gnome2     .ssh              .xauth64WO0N
.cache         .gvfs       .tcshrc           .xauthaxNdGo
.config        .java       .viminfo          .xauthaYG5v3
##.gitconfig文件记录用户邮件等信息
[root@foundation52 ~]# cat .gitconfig 
[user]
    name = hym
    email = 865700373@qq.com

查看文件状态:

[root@foundation52 ~]# cd demo/
[root@foundation52 demo]# git status -s
[root@foundation52 demo]# vim test.txt
########################
test
[root@foundation52 demo]# git status -s
?? test.txt
##第一次更改文件
[root@foundation52 demo]# vim readme.md 
########################
westos
westos
westos
##右侧M表示文件已经被更改 但并未添加到暂存区
[root@foundation52 demo]# git status -s
 M readme.md
?? test.txt
[root@foundation52 demo]# git add readme.md 
##左侧M表示文件已经被更改且已经添加到暂存区
[root@foundation52 demo]# git status -s
M  readme.md
?? test.txt
##第二次更改文件
[root@foundation52 demo]# vim readme.md 
westos
westos
westos
linux
两个M表示更改次数为2
[root@foundation52 demo]# git status -s
MM readme.md
?? test.txt
[root@foundation52 demo]# git add readme.md 
[root@foundation52 demo]# git status -s
M  readme.md
?? test.txt
[root@foundation52 demo]# git add test.txt 
[root@foundation52 demo]# git status -s
M  readme.md
A  test.txt
[root@foundation52 demo]# git commit -m "add test.txt"
[master 5c38794] add test.txt
 2 files changed, 4 insertions(+)
 create mode 100644 test.txt
[root@foundation52 demo]# git status -s

忽略(隐藏)文件:

一般我们总会有些文件无需纳入 Git 的管理,也不希望它们总出现在未跟踪文件列表。 通常都是些自动生成的文件,比如日志文件,或者编译过程中创建的临时文件等。
Git 忽略所有以 .o.a 结尾的文件。一般这类对象文件和存档文件都是编译过程中出现的.
Git 忽略所有以波浪符(~)结尾的文件,许多文本编辑软件(比如 Emacs)都用这样的文件名保存副本
[root@foundation52 demo]# ls
readme.md  test.txt
[root@foundation52 demo]# touch .file1
[root@foundation52 demo]# git status -s
?? .file1
##忽略(隐藏)以.开头的文件
[root@foundation52 demo]# cd .git/
[root@foundation52 .git]# ls
branches        config       HEAD   index  logs     refs
COMMIT_EDITMSG  description  hooks  info   objects
[root@foundation52 .git]# pwd
/root/demo/.git
[root@foundation52 .git]# vim .gitignore
[root@foundation52 .git]# cat .gitignore 
.*
[root@foundation52 .git]# cd .
[root@foundation52 .git]# ls
branches        config       HEAD   index  logs     refs
COMMIT_EDITMSG  description  hooks  info   objects
[root@foundation52 .git]# cd ..
[root@foundation52 demo]# ls
readme.md  test.txt
[root@foundation52 demo]# git status -s
?? .file1
[root@foundation52 demo]# mv .git/.gitignore .
[root@foundation52 demo]# git status -s

版本回退:

##查看日志
[root@foundation52 demo]# git log
commit 5c38794ece4d0844ef1606094bad3c3f75d03108
Author: hym <865700373@qq.com>
Date:   Fri Aug 24 09:41:25 2018 +0800

    add test.txt

commit bd67b193c8c028d03acb8e9710b8393517438da3
Author: root <root@foundation52.ilt.example.com>
Date:   Fri Aug 24 09:31:37 2018 +0800

    add readme.md
##查看简略日志
[root@foundation52 demo]# git log --pretty=oneline
5c38794ece4d0844ef1606094bad3c3f75d03108 add test.txt
bd67b193c8c028d03acb8e9710b8393517438da3 add readme.md
[root@foundation52 demo]# git status -s
[root@foundation52 demo]# cat readme.md 
westos
westos
westos  
linux
##版本回退(回退到第一次提交)
##HEAD表示当前版本 HEAD^则表示上一个版本
[root@foundation52 demo]# git reset --hard HEAD^
HEAD is now at bd67b19 add readme.md
[root@foundation52 demo]# cat readme.md 
westos
[root@foundation52 demo]# git log --pretty=oneline
bd67b193c8c028d03acb8e9710b8393517438da3 add readme.md
##relog记录了之前所有执行过的命令
[root@foundation52 demo]# git reflog
bd67b19 HEAD@{0}: reset: moving to HEAD^
5c38794 HEAD@{1}: commit: add test.txt
bd67b19 HEAD@{2}: commit (initial): add readme.md
##重置前一个提交
[root@foundation52 demo]# git reset --hard 5c38794
HEAD is now at 5c38794 add test.txt
[root@foundation52 demo]# git reflog
5c38794 HEAD@{0}: reset: moving to 5c38794
bd67b19 HEAD@{1}: reset: moving to HEAD^
5c38794 HEAD@{2}: commit: add test.txt
bd67b19 HEAD@{3}: commit (initial): add readme.md
[root@foundation52 demo]# cat readme.md 
westos
westos
westos  
linux

[root@foundation52 demo]# cat test.txt 
test
####更改文件
[root@foundation52 demo]# vim test.txt 
########################
test
heel
[root@foundation52 demo]# git status -s
 M test.txt
[root@foundation52 demo]# git status 
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   test.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
##撤销上一次更改
[root@foundation52 demo]# git checkout -- test.txt
[root@foundation52 demo]# cat test.txt 
test
##更改文件
[root@foundation52 demo]# vim test.txt
#########################
test westos 
[root@foundation52 demo]# git add test.txt 
[root@foundation52 demo]# git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   test.txt
#
##reset HEAD退回到暂存区
[root@foundation52 demo]# git reset HEAD test.txt 
Unstaged changes after reset:
M   test.txt
[root@foundation52 demo]# cat test.txt 
test westos
[root@foundation52 demo]# git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   test.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
##撤销上次更改
[root@foundation52 demo]# git checkout -- test.txt 
[root@foundation52 demo]# cat test.txt 
test

恢复已删除文件:

[root@foundation52 demo]# rm -f test.txt 
[root@foundation52 demo]# git status
# On branch master
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   deleted:    test.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
##直接撤销上次更改
[root@foundation52 demo]# git checkout -- test.txt
[root@foundation52 demo]# ls
readme.md  test.txt
[root@foundation52 demo]# cat test.txt 
test

彻底删除文件:

##彻底删除已经提交的文件
[root@foundation52 demo]# git rm test.txt 
rm 'test.txt'
[root@foundation52 demo]# git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   deleted:    test.txt
#
[root@foundation52 demo]# git status -s
D  test.txt
[root@foundation52 demo]# git commit -m "delete test.txt"
[master cbed7ee] delete test.txt
 1 file changed, 1 deletion(-)
 delete mode 100644 test.txt
[root@foundation52 demo]# git status -s

注册帐号:
这里写图片描述
用户登陆:
这里写图片描述
这里写图片描述
登陆时需要用之前添加的qq邮箱里做认证:
这里写图片描述
创建新项目:
这里写图片描述
这里写图片描述
选择ssh免密:
这里写图片描述

[root@foundation52 demo]# ls
readme.md
##添加远程仓库
[root@foundation52 demo]# git remote add origin https://github.com/hongyunmei/hongyunmei.git
##制作密匙
[root@foundation52 demo]# cd
[root@foundation52 ~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
22:d1:c6:5e:ca:04:2e:b9:c1:bc:a0:7f:fa:d4:8c:4f root@foundation52.ilt.example.com
The key's randomart image is:
+--[ RSA 2048]----+
|    .            |
| o o +           |
|. * o = .        |
|.. = * o         |
|. o . = S        |
| .   = .         |
|  . + E          |
|   + o           |
|  ... .          |
+-----------------+
[root@foundation52 ~]# cd .ssh/
[root@foundation52 .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
##查看公钥
[root@foundation52 .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMbp/L3bQGUPFeZYmJBLMNZBFC1CLlYMk0G6FqHnLwVfIFfGYVjLQSfsrIhB5zk8IHpH3y+Y4m7h4W80BC+/x4r4TIAFH8UPMJTFGBuKAD3hofeHOeZ+CSet1hy5xOYbLfBAeSJ1BartXDPT66DKuAVFEWl/gWb187Sim02IdWPvQ5GPd++9QGBPxaMzTSFNlqRFnxXeyERtO2fOJMPijIFDM2tHdikM/LqT8zqx1XWSsxKqehy6LHC8h+55z2Vqq5BvTp/MWp/WeCo3FkBfplejpvKFDmwvs9OfiXh1WAFY7uo42xzv20DqIscDtrRzQEZPhXkUhDHJSVG68O0esp root@foundation52.ilt.example.com

添加ssh认证
这里写图片描述
这里写图片描述

[root@foundation52 demo]# ls
readme.md
##将本地的master分支推送到origin主机
##如果选择了ssh方式则上传时无需输入用户和密码(我这里忘记选择了默认为http方式)
[root@foundation52 demo]# git push -u origin master
Username for 'https://github.com': hongyunmei
Password for 'https://hongyunmei@github.com': 
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (9/9), 686 bytes | 0 bytes/s, done.
Total 9 (delta 0), reused 0 (delta 0)
To https://github.com/hongyunmei/hongyunmei.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

(1).在物理机上更改文件内容 可在网页上查看到文件的变更

[root@foundation52 demo]# ls
readme.md
[root@foundation52 demo]# cat readme.md 
westos
westos
westos  
linux
[root@foundation52 demo]# vim test.txt
#########################
test
[root@foundation52 demo]# git add test.txt
[root@foundation52 demo]# git commit -m "add test.txt"
[master 260fcfc] add test.txt
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt
 ##上传 只有文件有所变更才能push
[root@foundation52 demo]# git push -u origin master
Username for 'https://github.com': hongyunmei
Password for 'https://hongyunmei@github.com': 
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 272 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/hongyunmei/hongyunmei.git
   cbed7ee..260fcfc  master -> master
Branch master set up to track remote branch master from origin.

测试:
这里写图片描述

(2).在网页上新建或者是更改文件内容 在物理机上可查看到文件的相应的变更

更改test.txt文件内容:
这里写图片描述
这里写图片描述
新建hello.txt文件:
这里写图片描述
这里写图片描述
这里写图片描述
测试:

[root@foundation52 demo]# git fetch origin
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/hongyunmei/hongyunmei
   78a1ade..ec09cf5  master     -> origin/master
[root@foundation52 demo]# ls
readme.md  test.txt
[root@foundation52 demo]# git pull origin
Updating 260fcfc..ec09cf5
Fast-forward
 hello.tex | 1 +
 test.txt  | 1 +
 2 files changed, 2 insertions(+)
 create mode 100644 hello.tex
[root@foundation52 demo]# ls
hello.tex  readme.md  test.txt
[root@foundation52 demo]# git branch
* master
[root@foundation52 demo]# cat test.txt 
test
linux
[root@foundation52 demo]# cat hello.tex 
hello world!
2.gitlab 服务器的搭建
[root@test1 ~]# ls
gitlab-ce-11.2.0-ce.0.el7.x86_64.rpm
[root@test1 ~]# yum install -y gitlab-ce-11.2.0-ce.0.el7.x86_64.rpm
[root@test1 ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2018-08-24 08:55:42 CST; 3h 36min ago
  Process: 734 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
  Process: 727 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  Process: 710 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
 Main PID: 1029 (master)
   CGroup: /system.slice/postfix.service
           ├─1029 /usr/libexec/postfix/master -w
           ├─1037 qmgr -l -t unix -u
           └─2060 pickup -l -t unix -u

Aug 24 08:55:41 test1 systemd[1]: Starting Postfix Mail Transport Agent...
Aug 24 08:55:42 test1 postfix/master[1029]: daemon started -- version 2.10.1...x
Aug 24 08:55:42 test1 systemd[1]: Started Postfix Mail Transport Agent.
Hint: Some lines were ellipsized, use -l to show in full.
[root@test1 ~]# cd /etc/gitlab/
[root@test1 gitlab]# ls
gitlab.rb
[root@test1 gitlab]# vim gitlab.rb 
####################
13 external_url 'http://172.25.52.11'
##此过程较为缓慢 耐心等待
[root@test1 gitlab]# gitlab-ctl reconfigure

设定新的用户密码
这里写图片描述
这里写图片描述
创建demo项目
这里写图片描述
这里写图片描述
选择ssh免密登陆
这里写图片描述

##查看公钥
[root@foundation52 ~]# cd .ssh/
[root@foundation52 .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[root@foundation52 .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMbp/L3bQGUPFeZYmJBLMNZBFC1CLlYMk0G6FqHnLwVfIFfGYVjLQSfsrIhB5zk8IHpH3y+Y4m7h4W80BC+/x4r4TIAFH8UPMJTFGBuKAD3hofeHOeZ+CSet1hy5xOYbLfBAeSJ1BartXDPT66DKuAVFEWl/gWb187Sim02IdWPvQ5GPd++9QGBPxaMzTSFNlqRFnxXeyERtO2fOJMPijIFDM2tHdikM/LqT8zqx1XWSsxKqehy6LHC8h+55z2Vqq5BvTp/MWp/WeCo3FkBfplejpvKFDmwvs9OfiXh1WAFY7uo42xzv20DqIscDtrRzQEZPhXkUhDHJSVG68O0esp root@foundation52.ilt.example.com

添加ssh认证
这里写图片描述

这里写图片描述

##克隆
[root@foundation52 ~]# git clone git@172.25.52.11:root/demo.git
Cloning into 'demo'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
[root@foundation52 ~]# cd demo/
[root@foundation52 demo]# ls
README.md
##添加远程仓库
[root@foundation52 demo]# git remote add origin git@172.25.52.11:root/demo.git
fatal: remote origin already exists.
##列出详细信息
[root@foundation52 demo]# git remote -v
origin  git@172.25.52.11:root/demo.git (fetch)
origin  git@172.25.52.11:root/demo.git (push)
[root@foundation52 demo]# vim README.md 
#########################
 1 # demo
 2 # hello word
##把文件从“工作区”添加到“暂存区
[root@foundation52 demo]# git add README.md
##提交
[root@foundation52 demo]# git commit -m "update README.md"
[master 3eaa07e] update README.md
 1 file changed, 1 insertion(+)
[root@foundation52 demo]# git push origin master 
Counting objects: 5, done.
Writing objects: 100% (3/3), 263 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@172.25.52.11:root/demo.git
   b1cee34..3eaa07e  master -> master

这里写图片描述

3. Jenkins服务的搭建
##添加网关
[root@test2 ~]# ip route add default via 172.25.52.250
[root@test2 ~]# vim /etc/resolv.conf 
##############
  1 # Generated by NetworkManager
  2 nameserver 114.114.114.114

[root@test2 ~]# ping baidu.com
^Z
[2]+  Stopped                 ping baidu.com
##把文件从"工作区"添加到"暂存区"
[root@foundation52 kiosk]# iptables -t nat -I POSTROUTING -s 172.25.52.0/24 -j MASQUERADE

[root@test2 ~]# ping baidu.com
PING baidu.com (123.125.115.110) 56(84) bytes of data.
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=1 ttl=49 time=62.7 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=2 ttl=49 time=44.7 ms
^Z
[3]+  Stopped                 ping baidu.com
##安装JDK和jenkins
[root@test2 ~]# ls
jdk-8u171-linux-x64.rpm  jenkins-2.121.3-1.1.noarch.rpm
[root@test2 ~]# yum install -y *
##开启服务
[root@test2 ~]# systemctl start jenkins
##查看到8080端口
[root@server2 ~]# netstat -antlp |grep :8080
tcp6       0      0 :::8080                 :::*                    LISTEN  

输入172.25.52.22
这里写图片描述

##获得解锁Jenkins密码
[root@test2 ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
b4c0bc944cf24c0d9c16c8722c9b7dd1

这里写图片描述
这里写图片描述
在 open menu 中将网页变更为中文版
安装插件:
这里写图片描述
设定用户及密码
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

##下载git
[root@test2 rpm]# yum install -y git 
##查看私钥
[root@foundation52 Desktop]# cd
[root@foundation52 ~]# cd .ssh/
[root@foundation52 .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[root@foundation52 .ssh]# cat id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAzG6fy920BlDxXmWJiQSzDWQRQtQi5WDJNBuhah5y8FXyBXxm
FYy0En7KyIQec5PCB6R98vmOJu4eFvNAQvv8eK+EyABR/FDzCUxRgbigA94aH3hz
nmfgknrdYcucTmGy3wQHkidQWq7Vwz0+ugyrgFRRFpf4Fm9fO0optNiHVj70ORj3
fvvUBgT8WjM00hTZakRZ8V3shEbTtnziTD4oyBQzNrR3YpDPy6k/M6sdV1krMSqn
ocuixwvIfuec9laquQb06fzFqf1ngqNxZAX6ZXo6byhQ5sL7PTn4l4dVgBWO7qON
sc79tA6iLHA7a0c0BGT4V5FIQxyUlRuvDtHrKQIDAQABAoIBAHIuJ1o6Td5pPya2
F4dL9KW6CloFGih7UmWkOReIQjIyDqc5v9qxZ7Ic1y3/fPKYyHp0SVR4RglAXdX7
rxy6mVzey47ZfvEqVVQQKEYH1HfUiUqigBEte6TUsul4S6kLsFgXbBMZmivMEuCl
SG+pu/BFJ7Uy1AHT2qDG31x+w7hLGWVIMO+dlELX1Xp5NtaUqz2QFvpFEYv+YFRJ
cOu37nI6UgQNQrOvVrcHa0QEtOVxa7AcMMj2lrOUuzNtDFcT/GLnBWu/7nONkczo
ksJUNTplUo6xoKxNH9CdWeXVPNnDm1kqVCfBb3gxC43Z9k48OQOEHIB5PTWAcqyI
f6IzrrECgYEA7gJRS4ocMwD08s5XfLhg0BvKwF7I4zJBPTm7kuAlxruZdqnfC6Ds
XOYB4td3EHxoz69wxTrvVG+OerD6cTBI9pF1M8ylt5yWbAHwxr0DPhd/7vDfKsI/
ET9MmbFFN9lpv72VhvkxxZME6SbSfn/3lT/+jy+/gOKacartIkTdhh8CgYEA2+KQ
WXWY6Kk4Q2H181pilpCrMikA/ljDrSDmiWDmNWKqUghK8/XitF7FXKv9C3grr0gK
1ohEZ1YYPQvVZNBfwiZe3Yu/je4ZFx/xh2lVNY7yLOqanesgNcOloADQCuor+8Ai
t/Tq09rfdERTYQwxKRsWQxPOGjEptLbMIee5lbcCgYBLLAo3HJDZfxTeV1OEfct+
DzkTVxyFvYqjZsealRb5VKkctHxQ9OuST8cKuVjOqSyFY/jvIjUS6wUKNTl0ZHa3
AawNxzYT7u4HgPlmG66ZftyWQBeMLruym9Z6uGWPRSjEOYGvlqckqtGjPfK/p3Uv
+31QBhmrAGcdPYoWB8AbqwKBgCa2/nlx1ilo2gorLlXZnTAraqkbRRyDXniWKWEY
2Y+evqRQ53mK2o6tfQxzD8u8Ldzfz2C0f26+XugotDra4XFatitF1sVTncFPk4Qn
DKSwdX1pFS4m3vX4a6n/WqIBVxstWi+PhOUmTV+4RAH7VpCJP2MyEoDUFSbHZKu3
lBqDAoGAeGyBRxC8pEWzwNHmVQEKM9uAclGcG3Hp+ilvYFb7VaGhnrAc4T2Og949
X60InjtkfI5Qmv+tJnNyLXOczQpd0HfY6Ot27wgDQNa3nHPx4budHzwc+1T5VPly
qYoaGDY3y0f4L6MqZ1P/V6vo/EG2vYVtQpJ0PgPC4YIvaNSTzWw=
-----END RSA PRIVATE KEY-----

这里写图片描述
添加私钥
这里写图片描述
5颗星表示每分钟
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
测试:

[root@foundation52 ~]# cd demo/
[root@foundation52 demo]# ls
README.md
[root@foundation52 demo]# vim test.txt
#########################
hello word!
[root@foundation52 demo]# git add test.txt
[root@foundation52 demo]# git commit -m "add test.txt"
[master 9d0c4fb] add test.txt
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt
[root@foundation52 demo]# git push origin master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 280 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@172.25.52.11:root/demo.git
   3eaa07e..9d0c4fb  master -> master

这里写图片描述
这里写图片描述

在jenkins里安装插件
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
在gitlab里
这里写图片描述
这里写图片描述
修改gitlab参数:

[root@test2 ~]# curl -X PUT --header "PRIVATE-TOKEN:ukufqG2i6yz5AxWPWDAW" 'http://172.25.52.11/api/v4/application/settings?allow_local_requests_from_hooks_and_services=true'

这里写图片描述
这里写图片描述

[root@foundation52 ~]# cd demo/
[root@foundation52 demo]# vim hello.txt
[root@foundation52 demo]# cat hello.txt 
hello word!
[root@foundation52 demo]# git add hello.txt
[root@foundation52 demo]# git status -s
A  hello.txt
[root@foundation52 demo]# git commit -m "add hello.txt"
[master a517cfe] add hello.txt
 1 file changed, 1 insertion(+)
 create mode 100644 hello.tx
[root@foundation52 demo]# git push origin master 
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 269 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To git@172.25.52.11:root/demo.git
   9d0c4fb..a517cfe  master -> master

这里写图片描述
这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值