Pass a Team City Parameter to a PowerShell file

12,336

Solution 1

If you put the parameter in quotes, "%version%", and change the script execution mode to Execute ps1 script with "-File" argument then this should resolve and inject correctly

e.g.

enter image description here

Hope this helps

Solution 2

You need Environment Variables (env.), it's work to me enter image description here

Share:
12,336
Ali Mst
Author by

Ali Mst

I am an IT Software Architect from Salt Lake City, Utah.

Updated on June 23, 2022

Comments

  • Ali Mst
    Ali Mst almost 2 years

    I have the following parameter defined in Team City:

    Team City Parameter

    I want to pass this parameter into a powershell script I have (that will update the xml file with the version number).

    Step With Parameter as Argument

    But this inserts the actual text %version% into the script (No substitution is made for the actual value of the parameter.)

    However, I know my script is working because if I hardcode the values like this then it works:

    Step with hard coded parameter

    Is there a way to get %version% to convert to the actual value when when used as a PowerShell script argument?

  • Ali Mst
    Ali Mst over 7 years
    I don't see the option to execute with the -File option in version 9. And I just upgraded to version 10 and it is not there either. I am guessing this is an option for older versions?
  • Ali Mst
    Ali Mst over 7 years
    Putting it in quotes was the solution. Once I did that it worked. Thanks!
  • Necoras
    Necoras almost 5 years
    Your example demonstrates adding environment variables to scripts which are written in the Team City UI, not source control as was specified in the original question. Your answer is not relevant to this situation.