I have a TeamCity project with the following build configurations:
Say I know whether I need to do it by changes to some file deps.txt
.
Here's what I want to do:
deps.txt
has changed, I want to run builds 1, then 2, then 3, then 4.deps.txt
has not changed, I want to run builds 2 then 3 then 4.I tried putting triggers on build configurations like this:
+:deps.txt
-:deps.txt
but if a commit includes changes deps.txt and other files, then configurations 1 and 2 trigger at the same time, meaning that configuration 2 will fail.
Is there an easy way to do this in TeamCity?
I would like to suggest a different approach:
a. Creating duplicate build configuration
b. Triggering the whole build chain from the last build.
The first chain of Build Configurations:
Gather dependencies: no trigger
Build: snapshot and artifact dependency on 1 on the same build chain, no trigger
Test: snapshot and artifact dependency on 2 on the same build chain, no trigger
Deploy: snapshot and artifact dependency on 3 on the same chain, VCS trigger on +:deps.txt
The second chain of Build Configurations:
Build: snapshot and artifact dependency on 1 on Last successful build, no trigger
Test: snapshot and artifact dependency on 5 on the same chain, no trigger
Deploy: snapshot and artifact dependency on 6 on the same chain, VCS trigger on any change -:deps.txt
In order to reduce duplicates you may use templates for 2 and 5, 3 and 6, 4 and 7.
You could combine 1 into 2, and then for the build step of 1 which gathers dependencies, write a custom script which uses the teamcity.build.changedFiles.file
property (see TeamCity docs) to check if deps.txt has actually changed or not, and then either gather dependencies or not. The rest of the build steps from 2 would then proceed as normal.
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