Superseded by artifact options in 2021.1+: https://blog.jetbrains.com/teamcity/2021/05/teamcity-2021-1-kotlin-and-node-js-build-runners-trigger-defined-parameters-high-availability-and-more/
AutoProperties provides a build feature that can set parameters based on whether or not the build was triggered by a person. It can also set different parameters depending on those that exist already. For example, you might want to change behaviour based on the amount of system memory available to an agent (teamcity.agent.hardware.memorySizeMb).
The plugin will run before any build steps are executed, so updated parameters will be immediately available.
AutoProperties came about as a partial solution to TW-6439 - Set custom parameters on automatic build triggering.
Add the feature to any build config or template:

Any number of parameters can be given. Spaces are trimmed from both the name and value.
As you type, the list will be tested for any target parameters that don't exist:

In this mode, the type of trigger that initiated the build is tested. For example, to set parameters only in builds started by VCS triggers, use 'vcs':

See "Testing" to find out the trigger type name for previous builds (previous names will also be listed when typing in this field). Note: the server doesn't currently provide any way to determine exactly which trigger was responsible.
In this mode, a list of available parameters will appear (this is aggregated from the build config as well as the last completed build, if there is one):

The regular expression to match against will be checked on save/test:

Click "Test on previous builds" to check which builds would qualify to have parameters set (this example is the character '2' in %build.number%):

For the 'By trigger type' setting, the trigger type name is listed in the rightmost column.
When builds are triggered indirectly as part of a dependency chain, they are treated as being triggered in the same way that the "responsible" build was. Use the test functionality to be sure of what will happen in these cases.
Warning: builds that are modified by AutoProperties are not considered to have customised parameters, unless the user specifies some in the Run dialog. This may have unintentional effects on build re-use, see "Suitable Builds" in the TeamCity documentation.
This plugin is built with Maven. To compile it, run the following in the root folder:
mvn package
- Add a timeout to the custom variable regex matcher to prevent catastrophic backtracking
- Investigate setting parameters on specific trigger (this isn't currently exposed in the API)