Ima*_*ong 5 git teamcity triggers build
我正在使用Teamcity作为git存储库的构建管理器;
目前,创建新构建的触发器是否有新的更改.
问题是,在构建时,我运行的脚本会创建一个名为version.txt的特定文件的新提交(我在那里增加数字).
成功完成后,提交被视为一个新的更改,并且在下一次运行时,即使没有进行其他提交,也会触发每晚构建.
我希望能够创建一个规则,如果唯一的更改挂起是对Version.txt文件,则不会触发构建.
有没有办法做到这一点?
编辑:我已经向团队城市添加了一个条件规则:如果version.txt文件已经更改,请不要触发构建(参见屏幕截图)但是,似乎这个规则会导致构建不被触发,例如,如果有2个挂起的更改,其中一个是version.txt文件
提前致谢.
是的,你可以做到。
这里有几个选项:
version.txt
在执行构建之前更新。使用 git hook 捕获提交,然后您可以更新构建并提交它,这样您将有 2 个提交,您的构建将执行这些提交 - 原始提交 + 版本更新
检查正在提交的文件的提交挂钩。如果唯一的文件是版本则跳过构建
post-merge
这是在用户将代码推送到远程分支后运行的钩子示例
#!/bin/sh
# Check to see if this is the first commit in the repository or not
if git rev-parse --verify HEAD >/dev/null 2>&1
then
# We compare our changes against the prevoius commit
against=HEAD^
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# Redirect output to screen.
exec 1>&2
# Check to see if we have updated the version.txt file
if [ $(git diff-tree -r --name-only $against | grep version.txt ) ];
then
# Output colors
red='\033[0;31m';
green='\033[0;32m';
yellow='\033[0;33m';
default='\033[0;m';
# personal touch :-)
echo "${red}"
echo " "
echo " |ZZzzz "
echo " | "
echo " | "
echo " |ZZzzz /^\ |ZZzzz "
echo " | |~~~| | "
echo " | |- -| / \ "
echo " /^\ |[]+ | |^^^| "
echo " |^^^^^^^| | +[]| | | "
echo " | +[]|/\/\/\/\^/\/\/\/\/|^^^^^^^| "
echo " |+[]+ |~~~~~~~~~~~~~~~~~~| +[]| "
echo " | | [] /^\ [] |+[]+ | "
echo " | +[]+| [] || || [] | +[]+| "
echo " |[]+ | || || |[]+ | "
echo " |_______|------------------|_______| "
echo " "
echo " "
echo " ${green}You have just commited code ${red} "
echo " Your code ${yellow}is bad.!!! ${red} Do not ever commit again "
echo " "
echo "${no_color}"
#fi;
exit 0;
Run Code Online (Sandbox Code Playgroud)