如何构建一个 git polling build bot? [英] How to build a git polling build bot?
本文介绍了如何构建一个 git polling build bot?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基于 cron、bash + make 的脚本(例如,比 Hudson 更小、更不健壮)构建机器人如何轮询 git 存储库并检测它是否应该现在构建 - 例如如果在从远程 git repo 定期拉取时,它已检索到新代码?
How can a little cron, bash + make based script (e.g. much smaller and less robust than, for example, Hudson) build-bot poll a git repo and detect if it should build now - e.g. if in its periodic pull from the remote git repo, it has retrieved new code?
目前,它看起来像这样:
Currently, it looks like this:
git fetch > build_log.txt 2>&1
if [ $? -eq 0 ]
then
echo "Fetch from git done";
git merge FETCH_HEAD >> build_log.txt 2>&1 ;
if [ $? -eq 0 ]
then
echo "Merge via git done"; ...
# builds unconditionally at the moment
fi
fi
推荐答案
如果没有获取任何内容,则get fetch"将不输出任何行,因此只需检查 build_log.txt 上的零文件大小:
If nothing was fetched, then "get fetch" will output no lines, so just check for zero filesize on build_log.txt:
git fetch > build_log.txt 2>&1
if [ -s build_log.txt ]
then
# build
fi
这篇关于如何构建一个 git polling build bot?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文