How not to run builds in Teamcity if only a specific file has changed

I work with Teamcity as a build manager in a git repository;

Currently, the trigger for creating a new assembly is if there are new changes.

The problem is that when I create the launch script, I create a new commit to a specific file called version.txt (I increase the number there).

Upon successful completion, the commit is considered a new change and in the next run, even if no other commits were made, the night assembly will be launched.

I want to be able to create a rule that will not run the assembly, unless the expected change relates to the Version.txt file.

Is there any way to do this?

edit: I added a command rule to the command city: do not start the assembly if the .txt version file has changed (see screenshot) however this rule seems to cause the assembly to not start if, for example, there are 2 pending changes , one of which relates to the version.txt file

enter image description here

early.

+5
source share
1 answer

Yes you can do it.
Here are a few options:


Update version.txt before building.

Use git capture to capture the commit, and then you can update the assembly and commit it so that you have 2 commits that will be executed by your assembly - original version + version update


Git hooks

Check commit commit commit files that were committed. If the only file is the version, skip the build

Here is an example post-merge binding that starts after a user clicks on a 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; 

Use grease to upgrade version

Version increment will be executed when adding code to the index ( git add ) enter image description here

+3
source

Source: https://habr.com/ru/post/1239407/


All Articles