Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass a Team City Parameter to a PowerShell file

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?

like image 576
Vaccano Avatar asked Aug 25 '16 22:08

Vaccano


People also ask

How do you pass parameters to a PowerShell script?

How do I pass parameters to PowerShell scripts? Passing arguments in PowerShell is the same as in any other shell: you just type the command name, and then each argument, separated by spaces. If you need to specify the parameter name, you prefix it with a dash like -Name and then after a space (or a colon), the value.

How do I pass multiple parameters to a PowerShell script?

To pass multiple parameters you must use the command line syntax that includes the names of the parameters. For example, here is a sample PowerShell script that runs the Get-Service function with two parameters. The parameters are the name of the service(s) and the name of the Computer.


2 Answers

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

like image 153
Evolve Software Ltd Avatar answered Sep 22 '22 12:09

Evolve Software Ltd


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

like image 40
Heavoc Avatar answered Sep 18 '22 12:09

Heavoc