The primer is correct; you can use %build.number% to insert the build number in your script. To broaden the answer, this is one of many TeamCity options predefined build options . If you enter the percent sign of opening in the code text field, TeamCity will display a drop-down menu containing all the possible parameters that you can insert.
You have to be careful about some because they are inserted as βsimpleβ words in your script. If, for example, you store shared configuration files in %agent.work.dir% and you try to run the following copy command:
cp %agent.work.dir%\config .\config
The team will be expanded by approximately
cp C:\teamcity install\config .\config
And this will not work, because Powershell will think that you are trying to copy the C:\teamcity . So make sure you specify the entire argument inside quotation marks:
cp "%agent.work.dir%\config" .\config
As a side note, using templates with custom configuration options is incredibly useful, so you can use the same scripts in multiple build configurations. This is like adding features to a language: you get reuse and ease of modification.
In addition, in versions of TeamCity prior to 7.1.1 there is an error related to running scripts with Script. The execution mode is set to -Command , therefore, if you use 7.0 or earlier versions, it is safer to use -File
source share