-服務(wù)器要開放22端口,對(duì)服務(wù)器git鉤子相關(guān)知識(shí)感興趣的朋友一起看看吧" />

欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

服務(wù)器添加git鉤子的步驟

 更新時(shí)間:2022年10月17日 14:23:01   作者:辛蕾亓  
這篇文章主要介紹了服務(wù)器添加git鉤子的步驟,配置碼云和服務(wù)器ssh
-服務(wù)器要開放22端口,對(duì)服務(wù)器git鉤子相關(guān)知識(shí)感興趣的朋友一起看看吧

又名git 寶塔 碼云 webhook鉤子自動(dòng)同步

第一步,在服務(wù)器下載,軟件,webhook。

第二步,查看git版本,不能太低。

這個(gè)太低了。

這個(gè)最新

第三步,

yum remove git 刪除git

yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm git最高版本

yum install git重新下載git最高版本

git config --global user.name XXX 郵箱名稱

git config --global user.email XX@XX.com 郵箱賬號(hào)

第四步,

配置碼云和服務(wù)器ssh

-服務(wù)器要開放22端口

https://baidu.physton.com/?q=%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%BC%80%E6%94%BE%E7%AB%AF%E5%8F%A3%E6%98%AF%E4%BB%80%E4%B9%88%E6%84%8F%E6%80%9D

云服務(wù)22端口:https://blog.csdn.net/qq_46311811/article/details/122233509

公鑰對(duì)添加(很重要):https://gitee.com/help/articles/4181#article-header0

暫時(shí)只支持一個(gè)碼云賬號(hào)同步生成公鑰對(duì)

ssh-keygen -t ed25519 -C "xxxxx@xxxxx.com" 這個(gè)就是公鑰對(duì)

cat /root/.ssh/id_ed25519.pub 這個(gè)是獲取公鑰對(duì)

第五步:git配置webhook。(WebHook)

下面peng哥的?。?!

git 寶塔 碼云 webhook鉤子自動(dòng)同步
linux git 安裝
centos8.0 以上 yum源自帶版本比較新的git 版本。
如果是centos7 版本要下載git最新版本的話,要下載ius yum源。(或者編譯安裝)
安裝完成后可配置用戶名和郵箱
git --global config user.name  XXX
git --global config user.email  xxx

配置碼云和服務(wù)器ssh
-服務(wù)器要開放22端口

暫時(shí)只支持一個(gè)碼云賬號(hào)同步
生成公鑰對(duì)
ssh-keygen -t ed25519 -C "xxxxx@xxxxx.com" //后面是郵箱 


生成的公鑰對(duì)在root/.ssh 里面
復(fù)制公鑰到碼云上面
git clone 到服務(wù)器
cd /www/wwwroot/
git clone git@gitee.com:fatcar/dmd_new.git 

配置寶塔webhook
#!/bin/bash
  
echo ""
#輸出當(dāng)前時(shí)間
date --date='0 days ago' "+%Y-%m-%d %H:%M:%S"
echo "Start"
#判斷寶塔WebHook參數(shù)是否存在
if [ ! -n "$1" ];
then 
          echo "param參數(shù)錯(cuò)誤"
          echo "End"
          exit
fi
#git項(xiàng)目路徑
gitPath="/www/wwwroot/$1"
#git 網(wǎng)址兩種方式都可以ssh 或者h(yuǎn)ttps
gitHttp="git@gitee.com:fatcar/$1.git"
#gitHttp="git@gitee.com:xxx/$1.git"
echo "Web站點(diǎn)路徑:$gitPath"
#判斷項(xiàng)目路徑是否存在
if [ -d "$gitPath" ]; then
        cd $gitPath
        #判斷是否存在git目錄
        if [ ! -d ".git" ]; then
                echo "在該目錄下克隆 git"
                sudo git clone $gitHttp gittemp
                sudo mv gittemp/.git .
                sudo rm -rf gittemp
        fi
        echo "拉取最新的項(xiàng)目文件"
        #sudo git reset --hard origin/master
        sudo git pull        
        echo "設(shè)置目錄權(quán)限"
        sudo chown -R www:www $gitPath
        echo "End"
        exit
else
        echo "該項(xiàng)目路徑不存在"
        echo "新建項(xiàng)目目錄"
        mkdir $gitPath
        cd $gitPath
        #判斷是否存在git目錄
        if [ ! -d ".git" ]; then
                echo "在該目錄下克隆 git"
                sudo git clone $gitHttp gittemp
                sudo mv gittemp/.git .
                sudo rm -rf gittemp
        fi
        echo "拉取最新的項(xiàng)目文件"
        #sudo git reset --hard origin/master
        sudo git pull
        echo "設(shè)置目錄權(quán)限"
        sudo chown -R www:www $gitPath
        echo "End"
        exit
fi

查看寶塔的密鑰 配置碼云上面的webhook
測(cè)試是否成功
分測(cè)試服務(wù)器和正式服務(wù)器(注意下分支)
--- 參考鏈接

https://www.itqaq.com/index/214.html
https://gitee.com/help/articles/4229#article-header0
https://www.cnblogs.com/jkko123/p/11620367.html
-- 思考

數(shù)據(jù)庫(kù)配置文件要不要傳到git(可以不用)因?yàn)槿绻诜?wù)器上面新加文件,不會(huì)影響同步,可以手動(dòng)添加數(shù)據(jù)庫(kù)文件
如果一些文件的權(quán)限需要777,會(huì)不會(huì)有影響。(待定)

到此這篇關(guān)于服務(wù)器添加git鉤子的文章就介紹到這了,更多相關(guān)服務(wù)器 git鉤子內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論