寶塔webhook布置gitee自動同步服務端


  • 服務端安裝git
    • yum install git
    • git - -version 查看git版本
    • git config —global user.name “myname"
    • git config —global user.email “myemail@qq.com"
    • ssh-keygen生成公鑰
  • 寶塔安裝webHook軟件
    • 新增shell腳本 例子見文檔最下方
    • 獲取密鑰
  • 碼雲設置項目webhook

 

#!/bin/bash
echo ""
#輸出當前時間
date --date='0 days ago' "+%Y-%m-%d %H:%M:%S"
echo "Start"
#判斷寶塔WebHook參數是否存在
if [ ! -n "$1" ];
then
    echo "param參數錯誤"
    echo "End"
    exit
fi
#git項目路徑
gitPath="/www/wwwroot/xxxxxx"
#git 網址
gitHttp="git@gitee.com:xxxxxx/xxxxxx.git"
 
echo "Web站點路徑:$gitPath"
 
#判斷項目路徑是否存在
if [ -d "$gitPath" ]; then
        cd $gitPath
        #判斷是否存在git目錄
        if [ ! -d ".git" ]; then
            echo "在該目錄下克隆 git"
            git clone $gitHttp gittemp
            mv gittemp/.git .
            rm -rf gittemp
        fi
        #拉取最新的項目文件
        git reset --hard origin/master
        git pull
        #設置目錄權限
        chown -R www:www $gitPath
        echo "End"
        exit
else
        echo "該項目路徑不存在"
        echo "End"
        exit
fi

  

 


免責聲明!

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



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