TeamCity CI Plugin: Enable filtering active branches based on Plastic SCM attributes.
The goal is to test and merge task branches to main only when a given attribute is set. This way trunk-based development and DevOps can be easily implemented.
The recommended configuration for TeamCity build configuration is as follows:
* Default branch to track in the VCS root is "/main".
* Branch specification for branches to monitor besides the default one in the VCS root is "+:(/main/*)" (The parenthesis are very important, as they define the logical TeamCity branch name, and has to match with plastic full branch name!).
* Enable the "Automatic merge" feature under the "Build features" section of the build configuration. Set the "Branch filter" to "+:*" so that TeamCity merges all that match the filter. Leave the other fields with the default values (the branches will be merged + checked-in to the default tracked branch "/main").
* Add "VCS Trigger" in "Trigger" section of the build configuration. Set the "Branch filter" to "+:*" too.
When configuring the VCS root for a build configuration, a new section named "Plastic SCM advanced branch filtering" will show up.
Once it is enabled, a textbox allows filtering the candidate branches to be visible by TeamCity in two ways:
* Specifying an attribute name and value pair as follows: attribute_name=attribute_value.
Example: status=resolved which means that only the branches with an attribute named "status" with the value "resolved" will be visible to TeamCity to queue & build them.
* Specifying a complex query valid for "cm find branch" command (which is the underlying Plastic command executed to retrieve the candidate branches). It is not mandatory to specify a plastic attribute in this mode. Two examples below:
where owner!='john_snow' and date > '3/2/2018'
where attribute='stage' and attrvalue='done' and name like 'JIRA-%'