How to retrieve system.teamcity.build.changedFiles.file property within powershell script
Build Runner config:
Build runner: Command Line
Working directory: C:\temp
Command executable: powershell
Command parameters: -command "& .\TeamCityTest.ps1 <HOW TO PASS PARAMETER???>"
I am trying to pass the "system.teamcity.build.changedFiles.file" parameter into a powershell script.
What is the syntax to accomplish this?
Please sign in to leave a comment.
TeamCity references are done with syntax %variable%.
The answer is to use : %system.teamcity.build.changedFiles.file%
I spent over 3 hours trying different combinations...
Here's my parameter field
-command "& .\TeamCityTest.ps1 %system.teamcity.build.changedFiles.file%"
Here's my powershell script
$testName = 'TeamCity test'
$i = 0
foreach($a in $args)
{
echo "### $i - $a"
$i = $i + 1
}
Here's the output?
[09:28:05]: Clearing temporary directory: C:\TeamCity\buildAgent\temp\buildTmp
[09:28:06]: Checkout directory: C:\TeamCity\buildAgent\work\bf0896ba254ac9a7
[09:28:06]: Parameter 'command.parameters=-command "& .\TeamCityTest.ps1 %system.teamcity.build.changedFiles.file%"' is not fully resolved, using as is.
[09:28:06]: Parameter 'system.changedFileLocation3=%system.teamcity.build.changedFiles.file%' is not fully resolved, using as is.
[09:28:06]: Parameter 'env.changedFileLocation2=%system.teamcity.build.changedFiles.file%' is not fully resolved, using as is.
[09:28:06]: Start process: powershell -command "& .\TeamCityTest.ps1 %system.teamcity.build.changedFiles.file%"
[09:28:06]: in: C:\temp
[09:28:07]: ### 0 - %system.teamcity.build.changedFiles.file%
[09:28:07]: Process exited with code 0
[09:28:07]: Build finished
Any more thoughts?
Jason,
Do you have changes in the build (e.g. on the build results Changes tab)? Currently, the property is not passed if there are no changes.
I gave it a shot again (and made sure there were changes). I am still seeing the below message.
Parameter 'command.parameters=-command "& .\TeamCityTest.ps1 %system.teamcity.build.changedFiles.file%"' is not fully resolved, using as is.
Any thoughts?
Do you find changeFiles*.txt file in build agent temp directory?
Please check property is named %system.teamcity.build.changedFiles.file%
Jason,
Seems, there is a bug that prevents %system.teamcity.build.changedFiles.file% from being propery resolved. The property is passed into the scripts as system. property, but so far cannot be used in the references.
I filed this as TW-11599.
Sorry for the inconvenience.
Good to hear - thanks for the update!