[英]How to not trigger a build in Teamcity if only a specific file changed
我正在使用Teamcity作為git存儲庫的構建管理器;
目前,創建新構建的觸發器是否有新的更改。
問題是,在構建時,我運行的腳本會創建一個名為version.txt的特定文件的新提交(我在那里增加數字)。
成功完成后,提交被視為一個新的更改,並且在下一次運行時,即使沒有進行其他提交,也會觸發每晚構建。
我希望能夠創建一個規則,如果唯一的更改掛起是對Version.txt文件,則不會觸發構建。
有沒有辦法做到這一點?
編輯:我已經向團隊城市添加了一個條件規則:如果version.txt文件已經更改,請不要觸發構建(參見屏幕截圖)但是,似乎這個規則會導致構建不被觸發,例如,如果有2個掛起的更改,其中一個是version.txt文件
提前致謝。
是的,你可以做到。
以下是幾個選項:
version.txt
。 使用git鈎子捕獲提交,然后你可以更新構建並提交它,這樣你將有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;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.