I am working with Teamcity as a build manager on a git repository;
currently, the trigger for creating a new build is if there are new changes.
the problem is, when building, the script i run creates a new commit of a specific file called version.txt (i increment the number there).
While finishing successfully, the commit is considered as a new change and on the next run , even if no other commits were made, the nightly build will be triggered.
I want to be able to create a rule that will not trigger a build if the only change pending is to the Version.txt file.
is there a way of doing that?
edit: I've added a condition rule to team city: do not trigger a build if version.txt file has changed(see screenshot) however, it seems this rule will cause the build not to be triggered if ,for instance, there are 2 pending changes which one of them is to the version.txt file
thanks in advance.
Yep, you can do it.
Here are several options:
version.txt
before you execute the build.Use a git hook to capture the commit and then you can update the build and commit it so you will have 2 commits which will your build will execute - the original one + the version update
Check in the commit hook for the files which are being committed. If the only file is the version then skip the build
Here is an example of post-merge
hook which runs after the user push code to the remote branch
#!/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;
The version increment will be done when adding code to the index (git add
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With