Git安裝及配置


官方文檔

https://git-scm.com/book/zh/v2

 

 

git 10.0.0.200

jenkins 10.0.0.201

 

Git准備環境
 getenforce
yum install git
 
        
[root@hostname200 ~]# git version
git version 1.8.3.1
[root@hostname200 ~]# git config
用法:git config [選項]
 
        
配置文件位置
    --global              使用全局配置文件
    --system              使用系統級配置文件
    --local               使用版本庫級配置文件
    -f, --file <文件>     使用指定的配置文件
    --blob <blob-id>      read config from given blob object
 
        
操作
    --get                 獲取值:name [value-regex]
    --get-all             獲得所有的值:key [value-regex]
    --get-regexp          根據正則表達式獲得值:name-regex [value-regex]
    --replace-all         替換所有匹配的變量:name value [value_regex]
    --add                 添加一個新的變量:name value
    --unset               刪除一個變量:name [value-regex]
    --unset-all           刪除所有匹配項:name [value-regex]
    --rename-section      重命名小節:old-name new-name
    --remove-section      刪除一個小節:name
    -l, --list            列出所有
    -e, --edit            打開一個編輯器
    --get-color <slot>    找到配置的顏色:[默認]
    --get-colorbool <slot>
                          找到顏色設置:[stdout-is-tty]
 
        
類型
    --bool                值是 "true" 或 "false"
    --int                 值是十進制數
    --bool-or-int         值是 --bool or --int
    --path                值是一個路徑(文件或目錄名)
 
        
其它
    -z, --null            終止值是NUL字節
    --includes            查詢時參照 include 指令遞歸查找
 
        

 

配置

 

[root@hostname200 ~]# git config --global user.name "ckh"
[root@hostname200 ~]# git config --global user.email 343264992@qq.com
[root@hostname200 ~]# git config --global color.ui true
[root@hostname200 ~]# git config --list
user.name=ckh
user.email=343264992@qq.com
color.ui=true
[root@hostname200 ~]# cat .gitconfig
[user]
 name = ckh
 email = 343264992@qq.com
[color]
 ui = true
 
        

 

GIT常規使用

git四種狀態

 

 branches # 分支目錄

 config   # 定義項目特有的配置選項

 description  # 僅供git web程序使用

 HEAD # 指示當前的分支

 hooks # 包含git鈎子文件

 info # 包含一個全局排除文件(exclude文件)

 objects # 存放所有數據內容,有info和pack兩個子文件夾

 refs # 存放指向數據(分支)的提交對象的指針

 index # 保存暫存區信息,在執行git init的時候,這個文件還沒有 

 

初始化目錄

[root@hostname200 ~]# mkdir git_data
[root@hostname200 ~]# cd git_data/
[root@hostname200 git_data]# git init
初始化空的 Git 版本庫於 /root/git_data/.git/
 
        
[root@hostname200 git_data]# git status
# 位於分支 master
#
# 初始提交
#
無文件要提交(創建/拷貝文件並使用 "git add" 建立跟蹤)
 
        
[root@hostname200 git_data]# touch a b c
[root@hostname200 git_data]# git status
# 位於分支 master
#
# 初始提交
#
# 未跟蹤的文件:
#   (使用 "git add <file>..." 以包含要提交的內容)
#
# a
# b
# c
提交為空,但是存在尚未跟蹤的文件(使用 "git add" 建立跟蹤)
[root@hostname200 git_data]# git add a
[root@hostname200 git_data]# git status
# 位於分支 master
#
# 初始提交
#
# 要提交的變更:
#   (使用 "git rm --cached <file>..." 撤出暫存區)
#
# 新文件:    a
#
# 未跟蹤的文件:
#   (使用 "git add <file>..." 以包含要提交的內容)
#
# b
# c
[root@hostname200 git_data]# git rm -f a
rm 'a'
[root@hostname200 git_data]# git status
# 位於分支 master
#
# 初始提交
#
# 未跟蹤的文件:
#   (使用 "git add <file>..." 以包含要提交的內容)
#
# b
# c
提交為空,但是存在尚未跟蹤的文件(使用 "git add" 建立跟蹤)
[root@hostname200 git_data]# ls
b  c
[root@hostname200 git_data]# git add b
[root@hostname200 git_data]# git commit -m "add file b"
[master(根提交) 0d0feec] add file b
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 b
[root@hostname200 git_data]# git status
# 位於分支 master
# 未跟蹤的文件:
#   (使用 "git add <file>..." 以包含要提交的內容)
#
# c
提交為空,但是存在尚未跟蹤的文件(使用 "git add" 建立跟蹤)
 
        
#每次提交的日志信息
[root@hostname200 git_data]# git log
commit caa84b88f31b5acdcf627b3359ca0719a5db2846
Author: ckh <343264992@qq.com>
Date:   Thu Nov 15 10:41:05 2018 +0800
 
        
    add file a c
 
        
commit 0d0feec1d0849c4496ed78631c223fd30876178e
Author: ckh <343264992@qq.com>
Date:   Thu Nov 15 10:25:28 2018 +0800
 
        
    add file b
 
        

 

 

MV改名 git認為是刪除了文件 然后回滾

[root@hostname200 git_data]# touch test
[root@hostname200 git_data]# git add test
[root@hostname200 git_data]# git status
# 位於分支 master
# 要提交的變更:
#   (使用 "git reset HEAD <file>..." 撤出暫存區)
#
# 新文件:    test
#
[root@hostname200 git_data]# mv test test.txt
[root@hostname200 git_data]# git status
# 位於分支 master
# 要提交的變更:
#   (使用 "git reset HEAD <file>..." 撤出暫存區)
#
# 新文件:    test
#
# 尚未暫存以備提交的變更:
#   (使用 "git add/rm <file>..." 更新要提交的內容)
#   (使用 "git checkout -- <file>..." 丟棄工作區的改動)
#
# 刪除:      test
#
# 未跟蹤的文件:
#   (使用 "git add <file>..." 以包含要提交的內容)
#
# test.txt
[root@hostname200 git_data]# git add test.txt
[root@hostname200 git_data]# git status
# 位於分支 master
# 要提交的變更:
#   (使用 "git reset HEAD <file>..." 撤出暫存區)
#
# 新文件:    test
# 新文件:    test.txt
#
# 尚未暫存以備提交的變更:
#   (使用 "git add/rm <file>..." 更新要提交的內容)
#   (使用 "git checkout -- <file>..." 丟棄工作區的改動)
#
# 刪除:      test
#
[root@hostname200 git_data]# git checkout  test
[root@hostname200 git_data]# ll
總用量 0
-rw-r--r-- 1 root root 0 11月 15 10:38 a
-rw-r--r-- 1 root root 0 11月 15 10:21 b
-rw-r--r-- 1 root root 0 11月 15 10:21 c
-rw-r--r-- 1 root root 0 11月 15 10:52 test
-rw-r--r-- 1 root root 0 11月 15 10:50 test.txt
 
        

 

撤回暫存區

[root@hostname200 git_data]# git reset HEAD test test.txt
[root@hostname200 git_data]# git status
# 位於分支 master
# 未跟蹤的文件:
#   (使用 "git add <file>..." 以包含要提交的內容)
#
# test
# test.txt
提交為空,但是存在尚未跟蹤的文件(使用 "git add" 建立跟蹤)
 
        

 

git mv 工作區和暫存區同時改

[root@hostname200 git_data]# ls
a  b  c  test  test.txt
[root@hostname200 git_data]# rm test.txt
rm:是否刪除普通空文件 "test.txt"?y
[root@hostname200 git_data]# git add test
[root@hostname200 git_data]# git status
# 位於分支 master
# 要提交的變更:
#   (使用 "git reset HEAD <file>..." 撤出暫存區)
#
# 新文件:    test
#
[root@hostname200 git_data]# git mv test test.txt
[root@hostname200 git_data]# git status
# 位於分支 master
# 要提交的變更:
#   (使用 "git reset HEAD <file>..." 撤出暫存區)
#
# 新文件:    test.txt
#
 
        

 

 

[root@hostname200 git_data]# echo aaa> test.txt
[root@hostname200 git_data]# ll
總用量 4
-rw-r--r-- 1 root root 0 11月 15 10:38 a
-rw-r--r-- 1 root root 0 11月 15 10:21 b
-rw-r--r-- 1 root root 0 11月 15 10:21 c
-rw-r--r-- 1 root root 4 11月 15 10:57 test.txt
[root@hostname200 git_data]# cat test.txt
aaa
[root@hostname200 git_data]# git status
# 位於分支 master
# 要提交的變更:
#   (使用 "git reset HEAD <file>..." 撤出暫存區)
#
# 新文件:    test.txt
#
# 尚未暫存以備提交的變更:
#   (使用 "git add <file>..." 更新要提交的內容)
#   (使用 "git checkout -- <file>..." 丟棄工作區的改動)
#
# 修改:      test.txt
#
 
        
#比對 工作目錄 和暫存區的文件不同
[root@hostname200 git_data]# git diff test.txt
diff --git a/test.txt b/test.txt
index e69de29..72943a1 100644
--- a/test.txt
+++ b/test.txt
@@ -0,0 +1 @@
+aaa
 
        
# 提交暫存區
[root@hostname200 git_data]# git add test.txt
[root@hostname200 git_data]# git diff test.txt # 沒有修改狀態信息
[root@hostname200 git_data]# git status #新文件
# 位於分支 master
# 要提交的變更:
#   (使用 "git reset HEAD <file>..." 撤出暫存區)
#
# 新文件:    test.txt
 
        
#提交倉庫
[root@hostname200 git_data]# git commit -m "add test.txt file aaa"
[master 4c5ce8b] add test.txt file aaa
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt
[root@hostname200 git_data]# git status
# 位於分支 master
無文件要提交,干凈的工作區
# 倉庫和暫存區 的區別
[root@hostname200 git_data]# git diff --cached test.txt
 
        
# 修改 在提交在比較
[root@hostname200 git_data]# echo bbb>>test.txt
[root@hostname200 git_data]# git add test.txt
[root@hostname200 git_data]# git diff --cached test.txt
diff --git a/test.txt b/test.txt
index 72943a1..dbee026 100644
--- a/test.txt
+++ b/test.txt
@@ -1 +1,2 @@
 aaa
+bbb
 
        
#這是 工作目錄 和暫存區對比
[root@hostname200 git_data]# git diff test.txt
[root@hostname200 git_data]# git diff #所有對比
 
        

 

已經在倉庫的文件 修改后快速提交 -am

[root@hostname200 git_data]# echo ccc>>test.txt
[root@hostname200 git_data]# cat test.txt
aaa
bbb
ccc
[root@hostname200 git_data]# git commit -am "add test file ccc"
[master 93bb2f6] add test file ccc
 1 file changed, 2 insertions(+)
[root@hostname200 git_data]# git status   #顯示工作區狀態
# 位於分支 master
無文件要提交,干凈的工作區
 
        
 
        

 

git基礎命令
git add file或git add . 將工作目錄文件添加到暫存區
git rm --cached 只刪暫存區
git rm -f file 刪除暫存區和工作目錄源文件,不會刪除倉庫里面的文件。
git status
git commit -m "修改了很多bug"
git checkout -- file 放棄工作區的改動,修改的部份會被回滾
git mv 這種改名操作會被跟蹤
git diff file 比對的工作目錄和暫存區域
git diff --cached file 比對暫存區和倉庫里的區別,前提是在工作區修改后要先將文件添加到暫存區才能比對git add file
git commit -am "日志" 適用於已要提交到倉庫的文件,如果在工作目錄修改了,可以直接這樣提交到倉庫,不需要再添加一次再提交。
git log查看日志
git log --oneline以單行顯示日志

 

# 提交日志記錄   oneline 一行簡單顯示信息
[root@hostname200 git_data]# git log --oneline
93bb2f6 add test file ccc
4c5ce8b add test.txt file aaa
caa84b8 add file a c
0d0feec add file b
 
        
# 多了 HEAD指向 最新一次提交信息   當前指針指向哪里
[root@hostname200 git_data]# git log --oneline --decorate
93bb2f6 (HEAD, master) add test file ccc
4c5ce8b add test.txt file aaa
caa84b8 add file a c
0d0feec add file b
 
        
#顯示每次版本修改的詳細信息
[root@hostname200 git_data]# git log -p
commit 93bb2f6caf31e6f78c80fcc9281a521f69447634
Author: ckh <343264992@qq.com>
Date:   Thu Nov 15 11:06:48 2018 +0800
 
        
    add test file ccc
 
        
diff --git a/test.txt b/test.txt
index 72943a1..1802a74 100644
--- a/test.txt
+++ b/test.txt
@@ -1 +1,3 @@
 aaa
+bbb
+ccc
 
        
# -2 顯示2條版本提交信息
[root@hostname200 git_data]# git log -2
commit 93bb2f6caf31e6f78c80fcc9281a521f69447634
Author: ckh <343264992@qq.com>
Date:   Thu Nov 15 11:06:48 2018 +0800
 
        
    add test file ccc
 
        
commit 4c5ce8b5200c48c6157e3a3f66cbc7780253e770
Author: ckh <343264992@qq.com>
Date:   Thu Nov 15 11:00:19 2018 +0800
 
        
    add test.txt file aaa
 
        

 

 

#倉庫 如何恢復 之前的版本

[root@hostname200 git_data]# echo dddd >test.txt
[root@hostname200 git_data]# ls
a  b  c  test.txt
[root@hostname200 git_data]# cat test.txt
dddd
[root@hostname200 git_data]# git commit -am "add dddd"
[master f634e8b] add dddd
 1 file changed, 1 insertion(+), 3 deletions(-)
[root@hostname200 git_data]# git status
# 位於分支 master
無文件要提交,干凈的工作區
[root@hostname200 git_data]# git log --oneline
f634e8b add dddd
93bb2f6 add test file ccc
4c5ce8b add test.txt file aaa
caa84b8 add file a c
0d0feec add file b
#回滾到 add a c 的內容
[root@hostname200 git_data]# git reset --hard caa84b8
HEAD 現在位於 caa84b8 add file a c  #提示指針回到 a c
 
        
[root@hostname200 git_data]# #假如回滾錯了 要回滾上一次的93bb2f6 add test file ccc
[root@hostname200 git_data]# git reflog   #查看所有記錄包括回滾記錄
caa84b8 HEAD@{0}: reset: moving to caa84b8
f634e8b HEAD@{1}: commit: add dddd
93bb2f6 HEAD@{2}: commit: add test file ccc
4c5ce8b HEAD@{3}: commit: add test.txt file aaa
caa84b8 HEAD@{4}: commit: add file a c
0d0feec HEAD@{5}: commit (initial): add file b
[root@hostname200 git_data]# git reset --hard 93bb2f6
HEAD 現在位於 93bb2f6 add test file ccc
[root@hostname200 git_data]# ls  #看test.txt 文件又回來咯
a  b  c  test.txt
[root@hostname200 git_data]# cat  test.txt
aaa
bbb
ccc
 
        

 

查看分支
[root@hostname200 git_data]# git branch
* master
# 創建分支 testing
[root@hostname200 git_data]# git branch tesing
[root@hostname200 git_data]# git branch
* master
  tesing
[root@hostname200 git_data]# git checkout tesing
切換到分支 'tesing'
[root@hostname200 git_data]# git branch
  master
* tesing  #當前在tesing分支上 *
 
        
[root@hostname200 git_data]# echo aaa>a
[root@hostname200 git_data]# git commit -am "add aaa"
[tesing aec3a92] add aaa
 1 file changed, 1 insertion(+)
[root@hostname200 git_data]# echo bbb>>a
[root@hostname200 git_data]# git commit -am "add bbb"
[tesing f7979d2] add bbb
 1 file changed, 1 insertion(+)
[root@hostname200 git_data]# echo ccc>>a
[root@hostname200 git_data]# git commit -am "add ccc"
[tesing eed1e8c] add ccc
 1 file changed, 1 insertion(+)
[root@hostname200 git_data]# git log --oneline --decorate
eed1e8c (HEAD, tesing) add ccc
f7979d2 add bbb
aec3a92 add aaa
4c5873b (master) add dddd
93bb2f6 add test file ccc
4c5ce8b add test.txt file aaa
caa84b8 add file a c
0d0feec add file b
 
        
分支操作
[root@hostname200 git_data]# git branch test
[root@hostname200 git_data]# git branch
* master
  tesing
  test
[root@hostname200 git_data]# git checkout test
切換到分支 'test'
[root@hostname200 git_data]# ll
總用量 8
-rw-r--r-- 1 root root  0 11月 15 14:59 a
-rw-r--r-- 1 root root  8 11月 15 14:59 b
-rw-r--r-- 1 root root  0 11月 15 10:21 c
-rw-r--r-- 1 root root 17 11月 15 11:51 test.txt
[root@hostname200 git_data]# git branch
  master
  tesing
* test
[root@hostname200 git_data]# git log --oneline --decorate
9615df2 (HEAD, test, master) add ccc
d286f32 add bbb
4c5873b add dddd
93bb2f6 add test file ccc
4c5ce8b add test.txt file aaa
caa84b8 add file a c
0d0feec add file b
[root@hostname200 git_data]# touch test
[root@hostname200 git_data]# git add .
[root@hostname200 git_data]# git commit -m "add branch test file"
[test 06f2b7e] add branch test file
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test
[root@hostname200 git_data]# git log --oneline --decorate
06f2b7e (HEAD, test) add branch test file
9615df2 (master) add ccc
d286f32 add bbb
4c5873b add dddd
93bb2f6 add test file ccc
4c5ce8b add test.txt file aaa
caa84b8 add file a c
0d0feec add file b
[root@hostname200 git_data]# git checkout master
切換到分支 'master'
[root@hostname200 git_data]# git log --oneline --decorate
9615df2 (HEAD, master) add ccc
d286f32 add bbb
4c5873b add dddd
93bb2f6 add test file ccc
4c5ce8b add test.txt file aaa
caa84b8 add file a c
0d0feec add file b
[root@hostname200 git_data]# touch master
[root@hostname200 git_data]# git add .
[root@hostname200 git_data]# git commit  -m "add branch master"
[master ede5984] add branch master
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 master
[root@hostname200 git_data]# git log --oneline --decorate
ede5984 (HEAD, master) add branch master
9615df2 add ccc
d286f32 add bbb
4c5873b add dddd
93bb2f6 add test file ccc
4c5ce8b add test.txt file aaa
caa84b8 add file a c
0d0feec add file b
[root@hostname200 git_data]# git branch
* master
  tesing
  test
#在 master主分支上合並test分支, 彈出vim直接:wq保存就可以
[root@hostname200 git_data]# git merge test
Merge made by the 'recursive' strategy.
 test | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test
[root@hostname200 git_data]# ll
總用量 8
-rw-r--r-- 1 root root  0 11月 15 14:59 a
-rw-r--r-- 1 root root  8 11月 15 14:59 b
-rw-r--r-- 1 root root  0 11月 15 10:21 c
-rw-r--r-- 1 root root  0 11月 15 15:08 master
-rw-r--r-- 1 root root  0 11月 15 15:12 test
-rw-r--r-- 1 root root 17 11月 15 11:51 test.txt #合並的文件
[root@hostname200 git_data]# git log --oneline --decorate
20d8851 (HEAD, master) Merge branch 'test' #指針指向合並后的test
ede5984 add branch master
06f2b7e (test) add branch test file
9615df2 add ccc
d286f32 add bbb
4c5873b add dddd
93bb2f6 add test file ccc
4c5ce8b add test.txt file aaa
caa84b8 add file a c
0d0feec add file b
 
        
[root@hostname200 git_data]# git checkout master
切換到分支 'master'
[root@hostname200 git_data]# git branch -D tesing
已刪除分支 tesing(曾為 1d4dcca)。
 
        
[root@hostname200 git_data]# git checkout testing
切換到分支 'testing'
 
        
  559  git status
  560  git checkout master
  561  echo lizhenya >>oldboy2.txt
  562  ll
  563  git staaus
  564  git status
  565  git add .
  566  git status
  567  git commit -m "add oldboy2.txt"
  568  git status
  569  git checkout testing
  570  ls
  571  git status
  572  ls
  573  git log --oneline --decorate
  574  echo
  575  ll
  576  git checkout master
  577  ll
  578  cat oldboy2.txt
  579  git checkout testing
  580  vim oldboy2.txt
  581  git add .
  582  git commit -m "add oldboy2.txt"
[root@hostname200 git_data]# git status
# 位於分支 testing
無文件要提交,干凈的工作區
[root@hostname200 git_data]# git checkout master
切換到分支 'master'
#合並時候 提示 oldboy.txt有沖突內容
[root@hostname200 git_data]# git merge testing
自動合並 oldboy.txt
沖突(添加/添加):合並沖突於 oldboy.txt
自動合並失敗,修正沖突然后提交修正的結果。
[root@hostname200 git_data]# vim oldboy
[root@hostname200 git_data]#
[root@hostname200 git_data]#
[root@hostname200 git_data]#
[root@hostname200 git_data]# vim oldboy.txt
[root@hostname200 git_data]#
[root@hostname200 git_data]#
[root@hostname200 git_data]# git merge testing
error: 'merge' is not possible because you have unmerged files.
提示:請先在工作區改正文件,然后酌情使用
提示:'git add/rm <file>' 標記解決方案,
提示:或使用 'git commit -a'。
fatal: Exiting because of an unresolved conflict.
 
        

 

git管理標簽

 

 #標簽是打的commit 提交的內容  可以用標簽名進行回滾
 git tag -a v1.0 -m "aaa bbb master tesing version v1.0" 
 git tag -a v2.0 -m "tag 2.0"
 git tag -a v2.0 dbead4c -m "add bbb version v2.0"
 git show v1.0
 git reset --hard v2.0
 git reset --hard v1.0
 git tag -d v2.0 
 
        

 

github
git remote add origin https://github.com/chengkanghua178/test.git
ssh-keygen
[root@hostname200 git_data]# cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6AdESjpuMKYuAsigzFGLYtmxPOTOM8hV74lx0n2+idAfwmr2XPncjJB7SrRFDzCyEsTCJfjWm2hArVaM6p9CgUubItnwwbmv11ZXfPvHJVqfcThi50nJklab8WcxRHTmcv6m2/RRqsnX2hsx4Zb8VG9Zzta/MGje0SHO4T1PXU9zNJOK+TKHhs4P8gjHbqJ96cyFsZxlnCUbhK/8IUmNLqELGzRithd1qVrgjtsYvBSWyL0ZGn9Dpp4I6EOPNXlxmrymhhHsrLXQvEmIk/CFtGIUBRN9FfJVQdG1+jK4Ap2zJWDDMMvUVov82f7gWV9lf98HwJAK6U180X2nDTFqx root@m01
 
        

 

[root@hostname200 git_data]# git push -u origin master
Username for 'https://github.com': chengkanghua178
Password for 'https://chengkanghua178@github.com':
Counting objects: 41, done.
Compressing objects: 100% (31/31), done.
Writing objects: 100% (41/41), 3.11 KiB | 0 bytes/s, done.
Total 41 (delta 13), reused 0 (delta 0)
remote: Resolving deltas: 100% (13/13), done.
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote:      https://github.com/chengkanghua178/test/pull/new/master
remote:
To https://github.com/chengkanghua178/test.git
 * [new branch]      master -> master
分支 master 設置為跟蹤來自 origin 的遠程分支 master。
 
        

 

git clone 克隆

 

[root@hostname200 git_data2]# git clone https://github.com/chengkanghua178/test.git
正克隆到 'test'...
remote: Enumerating objects: 41, done.
remote: Counting objects: 100% (41/41), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 41 (delta 13), reused 41 (delta 13), pack-reused 0
Unpacking objects: 100% (41/41), done.
 
        

 

gitlab

https://docs.gitlab.com.cn/

yum install -y curl policycoreutils-python openssh-server
[root@hostname200 ~]# rpm -ivh gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
[root@hostname200 ~]# rpm -ql gitlab-ce
#  gitlab 配置文件 更改url地址為本機IP地址
[root@hostname200 ~]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.137.200'
[root@hostname200 ~]# gitlab-ctl reconfigure #生效配置
Running handlers:
Running handlers complete
Chef Client finished, 382/541 resources updated in 02 minutes 03 seconds
gitlab Reconfigured!
成功~
瀏覽器訪問  http://192.168.137.200
 
        
/opt/gitlab/                    # gitlab的程序安裝目錄
/var/opt/gitlab                 # gitlab目錄數據目錄
/var/opt/gitlab/git-dfata       # 存放倉庫數據
 
        
gitlab-ctl status               # 查看目前gitlab所有服務運維狀態
gitlab-ctl stop                 # 停止gitlab服務
gitlab-ctl stop nginx           # 單獨停止某個服務
gitlab-ctl tail                 # 查看所有服務的日志
 
        
 gitlab漢化: 
1、下載漢化補丁
git clone https://gitlab.com/xhang/gitlab.git
2、查看全部分支版本
git branch -a
3、對比版本、生成補丁包
git diff remotes/origin/10-2-stable remotes/origin/10-2-stable-zh > ../10.2.2-zh.diff
4、停止服務器
gitlab-ctl stop
5、打補丁
patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /tmp/10.2.2-zh.diff 
6、啟動和重新配置
gitlab-ctl start
gitlab-ctl reconfigure
 
        

 

 

 

瀏覽器打開設置一個默認密碼 Ckh123.com

賬號默認是 root

 

[root@hostname200 git_data]# git remote
origin
[root@hostname200 git_data]# git remote remove origin  #刪除github遠程庫
[root@hostname200 git_data]# git add .
[root@hostname200 git_data]# git commit -m "Initial commit"
# 位於分支 master
無文件要提交,干凈的工作區
[root@hostname200 git_data]# git push -u origin master
The authenticity of host '192.168.137.200 (192.168.137.200)' can't be established.
ECDSA key fingerprint is SHA256:rWMnrnl8HcCIxl800ItSZocIvyA67fCVN+jU81bBThc.
ECDSA key fingerprint is MD5:dd:0a:91:99:5c:62:72:bb:de:76:58:4f:84:7b:85:d7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.137.200' (ECDSA) to the list of known hosts.
Counting objects: 41, done.
Compressing objects: 100% (31/31), done.
Writing objects: 100% (41/41), 3.11 KiB | 0 bytes/s, done.
Total 41 (delta 13), reused 0 (delta 0)
To git@192.168.137.200:oldboy/git_data.git
 * [new branch]      master -> master
分支 master 設置為跟蹤來自 origin 的遠程分支 master。
 
        

 

退出 用dev 賬號登陸 默認重新設置下密碼12345678

查看項目 能看到文件

 

dev 用戶使用 (開發者所使用賬號)
分發公鑰
ssh-keygen
 
        
[root@jenkins ~]# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHONq31HXSqd3A/ooHiWraDdFv45TvtJlMwSQTTMHuyb8o9NEdmyhyrbtTciGA1aUqggc+ojtKWlRFkPpTKYfhm/baFI9G2zSK+p+aUxYCrZ30CzlZ5Bus35CFt6JRchBWV0dnoqPqnmTKwTNRLANtxPqASeyrwyPziyoywqplhR7U2DquCqUGwnTdhwtu0VlFTzsw8Gkma2Or97nvkMSKUFWJwcov/YAxArVRPU7VmcOy9ozvxBC9pJg7jQBuCnj4u9Srx2UfKMVZiSmavGAAtFsXH4aChcw8owNs1R9ckv/Uv7BJjE35vN+5pFE84EEWHhz4a5TyscH3MdOJjQVN root@jenkins
 
        

 

 

[root@jenkins ~]# git clone git@192.168.137.200:oldboy/git_data.git
正克隆到 'git_data'...
The authenticity of host '192.168.137.200 (192.168.137.200)' can't be established.
ECDSA key fingerprint is SHA256:rWMnrnl8HcCIxl800ItSZocIvyA67fCVN+jU81bBThc.
ECDSA key fingerprint is MD5:dd:0a:91:99:5c:62:72:bb:de:76:58:4f:84:7b:85:d7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.137.200' (ECDSA) to the list of known hosts.
remote: Counting objects: 41, done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 41 (delta 13), reused 0 (delta 0)
接收對象中: 100% (41/41), done.
處理 delta 中: 100% (13/13), done.
[root@jenkins ~]# ls
anaconda-ks.cfg  git_data  ssh164.exp  ssh164.sh  y  y.pub
[root@jenkins ~]# cd git_data/
[root@jenkins git_data]# ls
a  b  c  master  oldboy2.txt  test  test.txt
 
        

 

創建分支

[root@jenkins git_data]# git branch dev
[root@jenkins git_data]# git branch
  dev
* master
[root@jenkins git_data]# git checkout dev
切換到分支 'dev'
 
        
[root@jenkins git_data]# touch dev
[root@jenkins git_data]# git add .
[root@jenkins git_data]# git commit -m "add dev"
 
        
*** Please tell me who you are.
 
        
Run
 
        
  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"
 
        
to set your account's default identity.
Omit --global to set the identity only in this repository.
 
        
fatal: unable to auto-detect email address (got 'root@jenkins.(none)')
# 提示配置個人信息
[root@jenkins git_data]# git config --global user.email "dev@example.com"
[root@jenkins git_data]# git config --global user.name "dev"
[root@jenkins git_data]# git commit -m "add dev"
[dev 6ee2585] add dev
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 dev
# 推送遠程倉庫
[root@jenkins git_data]# git push -u origin dev
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 218 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote:
remote: To create a merge request for dev, visit:
remote:   http://192.168.137.200/oldboy/git_data/merge_requests/new?merge_request%5Bsource_branch%5D=dev
remote:
To git@192.168.137.200:oldboy/git_data.git
 * [new branch]      dev -> dev
分支 dev 設置為跟蹤來自 origin 的遠程分支 dev。
 
        

 

小結 上面dev操作

git branch dev
git checkout dev
touch dev
git add .
git commit -m "add dev"
git config --global user.email "dev@example.com"
git config --global user.name "dev"
git commit -m "add dev"
git push -u origin dev
 
        

 

dev 用戶默認可以推送 master主干代碼
[root@jenkins git_data]# git branch
  dev
* master
[root@jenkins git_data]#
[root@jenkins git_data]#
[root@jenkins git_data]#
[root@jenkins git_data]#
[root@jenkins git_data]#
[root@jenkins git_data]#
[root@jenkins git_data]#
[root@jenkins git_data]# touch oldgirl
[root@jenkins git_data]# git add .
[root@jenkins git_data]# git commit -m "add oldgirl"
[master 7ba29f7] add oldgirl
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 oldgirl
 
        
[root@jenkins git_data]# git commit -m "add oldgirl"
[master 7ba29f7] add oldgirl
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 oldgirl
[root@jenkins git_data]# git push -u origin master
To git@192.168.137.200:oldboy/git_data.git
 ! [rejected]        master -> master (fetch first)
error: 無法推送一些引用到 'git@192.168.137.200:oldboy/git_data.git'
提示:更新被拒絕,因為遠程版本庫包含您本地尚不存在的提交。這通常是因為另外
提示:一個版本庫已推送了相同的引用。再次推送前,您可能需要先合並遠程變更
提示:(如 'git pull')。
提示:詳見 'git push --help' 中的 'Note about fast-forwards' 小節。
 
        
#返回master端測試推送,由於其他分支進行推送,和master端內容不一致,所以無法進行推送,使用git pull把代碼拉取到本地,或者git fetch 把代碼拉取到本地倉庫后進行合並(注意:git pull = git tetch+git merge)
[root@jenkins git_data]# git pull
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (1/1), done.
來自 192.168.137.200:oldboy/git_data
   9456d1b..73d13d6 master -> origin/master
Merge made by the 'recursive' strategy.
 dev | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 dev
[root@jenkins git_data]# git push -u origin master
Counting objects: 6, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 464 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
To git@192.168.137.200:oldboy/git_data.git
   73d13d6..9e5dfe5 master -> master
分支 master 設置為跟蹤來自 origin 的遠程分支 master。
 
        
 每次操作前  git  pull(下載遠程代碼)   操作后  git push(推送代碼遠端)
 
        

 

保護master 分支不可以被合並 dev用戶不可以

 

[root@jenkins git_data]# git branch
  dev
* master
[root@jenkins git_data]# touch 1.txt
[root@jenkins git_data]# git add .
[root@jenkins git_data]# git commit -m "add 1.txt"
[master 1aee1da] add 1.txt
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 1.txt
[root@jenkins git_data]# git push -u origin master
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 228 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: GitLab: You are not allowed to push code to protected branches on this project.
To git@192.168.137.200:oldboy/git_data.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: 無法推送一些引用到 'git@192.168.137.200:oldboy/git_data.git'
 
        

 

dev賬號 只能推送dev分支的
[root@jenkins git_data]# git branch
  dev
* master
[root@jenkins git_data]# git branch -D dev
已刪除分支 dev(曾為 6ee2585)。
 
        

 

[root@jenkins git_data]# git branch dev
[root@jenkins git_data]# git status
# 位於分支 master
# 您的分支領先 'origin/master' 共 1 個提交。
#   (使用 "git push" 來發布您的本地提交)
#
無文件要提交,干凈的工作區
[root@jenkins git_data]# git branch dev
fatal: 一個分支名 'dev' 已經存在。
[root@jenkins git_data]# git checkout dev
切換到分支 'dev'
[root@jenkins git_data]# git push -u origin dev #下載遠端dev分支代碼
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 228 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote:
remote: To create a merge request for dev, visit:
remote:   http://192.168.137.200/oldboy/git_data/merge_requests/new?merge_request%5Bsource_branch%5D=dev
remote:
To git@192.168.137.200:oldboy/git_data.git
   6ee2585..1aee1da dev -> dev
分支 dev 設置為跟蹤來自 origin 的遠程分支 dev。
 
        
[root@jenkins git_data]# git status
# 位於分支 dev
# 您的分支領先 'origin/dev' 共 1 個提交。
#   (使用 "git push" 來發布您的本地提交)
#
無文件要提交,干凈的工作區
[root@jenkins git_data]# git branch
* dev
  master
[root@jenkins git_data]# touch dev2.txt
[root@jenkins git_data]# git add .
[root@jenkins git_data]# git commit -m "add dev2.txt"
[dev b9767dc] add dev2.txt
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 dev2.txt
[root@jenkins git_data]# git push -u origin dev #推送遠端服務器
Counting objects: 5, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 391 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote:
remote: To create a merge request for dev, visit:
remote:   http://192.168.137.200/oldboy/git_data/merge_requests/new?merge_request%5Bsource_branch%5D=dev
remote:
To git@192.168.137.200:oldboy/git_data.git
   1aee1da..b9767dc  dev -> dev
分支 dev 設置為跟蹤來自 origin 的遠程分支 dev。
 
        

網頁刷新查看dev分支有dev2.txt

 

 

jenkins
官網 jenkins.io
Jenkins是一個開源軟件項目,是基於Java開發的一種持續集成工具,用於監控持續重復的工作,旨在提供一個開放易用的軟件平台,使軟件的持續集成變成可能。
 
        
1.安裝准備
裝備兩台服務器 關閉selinux和防火牆
內存2G 50G+硬盤
jenkins  10.0.0.201
nexus    10.0.0.202
 
        
2.安裝JDK運行環境和jenkins服務
上傳JDK和jenkins rpm安裝包,使用rpm -ivh進行安裝,安裝完JDK運維java測試是否安裝成功
rpm -ivh jdk-8u181-linux-x64.rpm
rpm -ivh jenkins-2.99-1.1.noarch.rpm
 
        
3.配置jenkins
[root@jenkins git_data]# rpm -ql jenkins
/etc/init.d/jenkins
/etc/logrotate.d/jenkins
/etc/sysconfig/jenkins   #配置文件
/usr/lib/jenkins
/usr/lib/jenkins/jenkins.war jenkins安裝目錄,WAR包會放在這里
/usr/sbin/rcjenkins
/var/cache/jenkins
/var/lib/jenkins
/var/log/jenkins
 
        
啟動用戶修改為root
JENKINS_USER="root"
[root@jenkins git_data]# sed -i '/JENKINS_USER=/c JENKINS_USER="root"' /etc/sysconfig/jenkins
[root@CentOS7 ~]# systemctl start jenkins
[root@CentOS7 ~]# systemctl enable jenkins
訪問頁面進行配置
http://192.168.137.201:8080
 
        
[root@jenkins git_data]# cat /var/lib/jenkins/secrets/initialAdminPassword
8d1f0c036b304eb9a9f5c2464817d405
 
        
登陸 輸入密碼 解鎖

 

4.插件安裝(跳過安裝插件,直接上傳插件到目錄)和修改登錄密碼
 
        
  1.自動安裝可選插件
  2.手動下載插件上傳安裝
  3.插件放入插件目錄
    [root@CentOS7 ~]# cd /var/lib/jenkins/
    [root@CentOS7 jenkins]# ll      jobs為每次構建后構建的結果目錄,plugins為插件目錄
    總用量 36
    -rw------- 1 root root 1822 8月  26 00:35 config.xml
    -rw------- 1 root root  156 8月  26 00:31 hudson.model.UpdateCenter.xml
    -rw------- 1 root root 1712 8月  26 00:32 identity.key.enc
    -rw------- 1 root root   94 8月  26 00:32 jenkins.CLI.xml
    -rw-r--r-- 1 root root    4 8月  26 00:35 jenkins.install.InstallUtil.lastExecVersion
    -rw-r--r-- 1 root root    4 8月  26 00:35 jenkins.install.UpgradeWizard.state
    drwxr-xr-x 2 root root    6 8月  26 00:31 jobs
    drwxr-xr-x 3 root root   18 8月  26 00:32 logs
    -rw------- 1 root root  907 8月  26 00:32 nodeMonitors.xml
    drwxr-xr-x 2 root root    6 8月  26 00:32 nodes
    drwxr-xr-x 2 root root    6 8月  26 00:31 plugins #插件目錄
    -rw------- 1 root root   64 8月  26 00:31 secret.key
    -rw-r--r-- 1 root root    0 8月  26 00:31 secret.key.not-so-secret
    drwx------ 4 root root 4096 8月  26 00:32 secrets
    drwxr-xr-x 2 root root   23 8月  26 00:32 userContent
    drwxr-xr-x 3 root root   18 8月  26 00:34 users
    上傳插件包解壓到plugins下執行重啟  systemctl restart jenkins
 
        
[root@jenkins jenkins]# tree users
users
└── admin
    └── config.xml    #用戶配置文件
 
        
#上傳插件文件
[root@jenkins plugins]# rz -E
rz waiting to receive.
[root@jenkins plugins]# ls
plugins.tar.gz
[root@jenkins plugins]# tar xf plugins.tar.gz
[root@jenkins plugins]# mv plugins.tar.gz /tmp/
[root@jenkins plugins]# mv plugins/* ./
[root@jenkins plugins]# systemctl restart jenkins
刷新網頁 從新登陸  默認賬號admin  密碼是剛剛設置的123

 

 
        
4.jenkins主要的目錄
/usr/lib/jenkins/:jenkins安裝目錄,WAR包會放在這里
/etc/sysconfig/jenkins:jenkins配置文件,“端口”,“JENKINS_HOME”等都可以在這里配置
/var/lib/jenkins/:默認的JENKINS_HOME
/var/log/jenkins/jenkins.log:Jenkins日志文件
 
        
5.創建一個自由風格的項目freestyle-job
 
        

 

創建第一個項目

[root@jenkins workspace]# pwd
/var/lib/jenkins/workspace
[root@jenkins workspace]# tree
.
└── freestyle-job
    └── test.txt
 
        
1 directory, 1 file
 
        

 

再啟動一台ip 202 安裝nginx
[root@web01 ~]# yum install -y nginx #這里用的是阿里雲倉庫默認倉庫yum源 
[root@web01 ~]# systemctl start nginx
[root@web01 ~]# netstat -lntup |grep 80
tcp        0      0 0.0.0.0:80 0.0.0.0:* LISTEN 1068/nginx: master
tcp6       0      0 :::80 :::* LISTEN 1068/nginx: master
[root@web01 ~]# cd /usr/share/nginx/html/
[root@web01 html]# ls
404.html  50x.html index.html nginx-logo.png poweredby.png
 
        

 

再碼雲上找一個開源的項目

https://gitee.com/kangjie1209/monitor

 

gitlab 導入,碼雲的開源項目代碼

 

 

202ip web主機手動上線代碼
[root@web01 data]# cd /usr/share/nginx/html/
[root@web01 html]# git clone https://gitee.com/kangjie1209/monitor.git
[root@web01 html]# ls
404.html  50x.html  index.html  monitor  nginx-logo.png  poweredby.png
 
        

 

 

 

 

 

 

# jenkins 項目目錄  Building in workspace /var/lib/jenkins/workspace/freestyle-job/
 
        
[root@jenkins jenkins]# cd /var/lib/jenkins/
[root@jenkins jenkins]# ls
 
        

 

 

​ 寫一個腳本把從git倉庫里獲取的代碼上傳到web服務器站點目錄下
[root@jenkins scripts]# pwd
/server/scripts
[root@jenkins scripts]# cat deploy.sh
#!/bin/sh
DATE=$(date +%Y-%m-%d-%H-%M-%S)
CODE_DIR="/var/lib/jenkins/workspace/freestyle-job"
WEB_DIR="/usr/share/nginx/"
 
        
get_code_tar(){
        cd $CODE_DIR && tar zcf /opt/web-$DATE.tar.gz ./*
}
 
        
scp_code_web(){
        scp /opt/web-$DATE.tar.gz 192.168.137.202:$WEB_DIR
}
 
        
code_tarxf(){
        ssh 192.168.137.202 "cd $WEB_DIR &&mkdir web-$DATE && tar xf web-$DATE.tar.gz -C web-$DATE"
 
        
}
ln_html(){
         ssh 192.168.137.202 "cd $WEB_DIR && rm -rf html && ln -s web-$DATE html"
}
 
        
main(){
 
        
        get_code_tar;
        scp_code_web;
        code_tarxf;
        ln_html;
}
main
 
        
 
        

 

 

[root@jenkins scripts]# ssh-keygen  #分發秘鑰
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
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:
SHA256:n8WMHpGSpz9lokNh98eJmWmSfhdF0+4Ptr2r4trVIVI root@jenkins
The key's randomart image is:
+---[RSA 2048]----+
|               .o|
|         . .   .o|
|        = =  E ..|
|       . * B.* o.|
|        S *.&.=o |
|       . * X..=.o|
|        o B .o.=.|
|         ..+... o|
|         .oo...oo|
+----[SHA256]-----+
[root@jenkins scripts]# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.137.202
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.137.202 (192.168.137.202)' can't be established.
ECDSA key fingerprint is SHA256:rWMnrnl8HcCIxl800ItSZocIvyA67fCVN+jU81bBThc.
ECDSA key fingerprint is MD5:dd:0a:91:99:5c:62:72:bb:de:76:58:4f:84:7b:85:d7.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.137.202's password:
 
        
Number of key(s) added: 1
 
        
Now try logging into the machine, with: "ssh '192.168.137.202'"
and check to make sure that only the key(s) you wanted were added.
 
        
# 運行推送腳本 201 jenkins主機上
[root@jenkins scripts]# sh deploy.sh
web-2018-11-16-16-14-45.tar.gz                                              100% 4545KB 60.9MB/s 00:00
 
        
# 202web主機 查看推送的文件
[root@web01 nginx]# pwd
/usr/share/nginx
# html軟鏈接到了 web-`日期`  的目錄上的
[root@web01 nginx]# ll
總用量 4552
lrwxrwxrwx 1 root root      23 11月 16 16:14 html -> web-2018-11-16-16-14-45
drwxr-xr-x 2 root root     170 11月 5 21:26 modules
drwxr-xr-x 8 root root    4096 11月 16 16:14 web-2018-11-16-16-14-45
-rw-r--r-- 1 root root 4653885 11月 16 16:14 web-2018-11-16-16-14-45.tar.gz
 
        

瀏覽器訪問192.168.137.202

 

jenkins 配置

 

 

 

#開發主機克隆代碼 修改 再推送

[root@hostname200 ~]# git clone git@192.168.137.200:oldboy/monitor.git
正克隆到 'monitor'...
remote: Counting objects: 435, done.
remote: Compressing objects: 100% (372/372), done.
remote: Total 435 (delta 53), reused 435 (delta 53)
接收對象中: 100% (435/435), 8.78 MiB | 0 bytes/s, done.
處理 delta 中: 100% (53/53), done.
[root@hostname200 ~]# ls
[root@hostname200 ~]# cd monitor/
[root@hostname200 monitor]# ls
[root@hostname200 monitor]# vim index.html
[root@hostname200 monitor]# git add .
[root@hostname200 monitor]# git commit -m "add index.html"
[master 12e743e] add index.html
 1 file changed, 1 insertion(+), 1 deletion(-)
[root@hostname200 monitor]# git push -u origin master
Counting objects: 5, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 297 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To git@192.168.137.200:oldboy/monitor.git
   f6070e1..12e743e  master -> master
分支 master 設置為跟蹤來自 origin 的遠程分支 master。
 
        

 

報錯檢查
只有一個主分支master  git ip200服務器上創建dev分支
git branch dev
git checkout dev
git branch
 
        

 

JENKINS主機上的公鑰 貼到gitlab 的dev 用戶sshkey上
[root@jenkins ~]# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+3DOFCwyImeBJrhoPDB8aoGs/4+aNJXWJv4THMPDwWgW1PdF94fCslLRx/jWSWAiRoCPIlhMZ5673vi94iXaCK+AgwnF//eMVe1RDnZfzaKBrL6RuQDrwa64o8yOK3yNtwxP0BE3kEMCV3A8jZixc4CvjyoFg+1+u9bxhx+3untZh2+ZUB9izxdLFEtDJmahC+N2+deKksl+4H2ArDa5YijVkUQdesEVw2ta5ol0XInUzawwydk6JAbAmUWK15bWloN/I+IptIXVgYym2WoCrBvrVOVqaOsh34x9muD+pAT2LhnkRNxpozBjiwfr7pUE7LEF1CEfPHzmMGCjO91Nn root@jenkins
 
        

 

jenkins配置

 

 

上面的 url: http的地址 和 Secret token 秘鑰復制到 gitlab web鈎子 綁定項目事件頁面上

 

 

git主機上測試修改代碼 推送

  cd /tmp/
  git clone git@192.168.137.200:oldboy/monitor.git
  cd monitor/
  ll
  vim index.html
  git status
  git add .
  git commit -m "add index"
  git push -u origin master
 
        

刷新網頁查看 標題修改了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM