前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >使用git钩子搭建自动化持续集成方案,本地--git中央仓库--项目发布环境

使用git钩子搭建自动化持续集成方案,本地--git中央仓库--项目发布环境

作者头像
躺平程序员老修
发布2023-09-05 15:46:09
1750
发布2023-09-05 15:46:09
举报
文章被收录于专栏:躺平程序员老修

git

坑待填

COPY SSHKEY

代码语言:javascript
复制
ssh-copy-id user@ip

POST-RECEIVE

代码语言:javascript
复制
#!/bin/bash
WEBDIR=/var/www/html/
git --work-tree=${WEBDIR} clean -fd
git --work-tree=${WEBDIR} checkout -f
代码语言:javascript
复制
#!/bin/sh
#
# An example hook script for the "post-receive" event.
#
# The "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated.  It is passed arguments in through
# stdin in the form
#  <oldrev> <newrev> <refname>
# For example:
#  aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
#
# see contrib/hooks/ for a sample, or uncomment the next line and
# rename the file to "post-receive".

#. /usr/share/git-core/contrib/hooks/post-receive-email
#git 仓库 
while read oldrev newrev ref
do
    branch=$(git rev-parse --symbolic --abbrev-ref $ref)
    if [ "$branch" = "master" ]
    then
        git push -f fenke:/mob/fenke.git $branch
    else
        git push -f fenke_test:/mob/fenke.git $branch
    fi
done




# 项目服务器(也搭建一个git仓库)
while read oldrev newrev ref
do
    if [[ $ref =~ .*/3.0$ ]];
    then
        echo "test ref received.  Deploying fenke3.0 branch to test server..."
        git --work-tree=/var/www/html/test --git-dir=$GIT_DIR checkout -f $ref
    else
        echo "Ref $ref successfully received.  Doing nothing: only the 3.0 branch may be deployed on this server."
    fi
done
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 坑待填
  • COPY SSHKEY
  • POST-RECEIVE
相关产品与服务
持续集成
CODING 持续集成(CODING Continuous Integration,CODING-CI)全面兼容 Jenkins 的持续集成服务,支持 Java、Python、NodeJS 等所有主流语言,并且支持 Docker 镜像的构建。图形化编排,高配集群多 Job 并行构建全面提速您的构建任务。支持主流的 Git 代码仓库,包括 CODING 代码托管、GitHub、GitLab 等。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档