Passing configuration parameters to shell build script

Hi,

I've created a configuration parameter called app.name with a default value of MyApp in the Build Parameters section.

Then in my Build Step I used %app.name% in the Command Parameters textbox.

My question is, how do I get a reference to that app.name parameter from within my shell build script?

I've been trying also sort of combinations with no success...

EDIT: Using Team City 7 Professional

Thanks

0
8 comments

For that you need to declare it as environment variable
Capture.PNG

0
Avatar
Permanently deleted user

Hi Michael,

Thanks for your reply.

But how would I then reference those env variables in my build script?

Thanks

0

By this name, but without env. prefix

0
Avatar
Permanently deleted user

Thanks.

I've tried testing things out with the following but with no success:

echo %env.build.number%

echo build.number
echo %custom.paramater%



Guess I'm missing something here?
0

Hello,

   I'd suggest 2 things:

   - use environment variable name without dots in TC settings: env.MY_APP_NAME = value
   - Reference environment variable in Windows shell script as %MY_APP_NAME%

  Hope this helps,
  KIR

0
Avatar
Permanently deleted user

Hi,

Thanks for getting back to me.

I did as you suggested but is still unable to reference my env variables from a shell script.

I use: %build.number% (system parameter) and %APP_NAME% (enviroment parameter).

Is it any different for windows shell scripts vs unix shell scripts? Because I'm trying to get this to work using on a Mac OS X enviroment.

Thanks

0
Avatar
Permanently deleted user

Ryno, yes, the syntax for expanding environment variables differs between Windows and Unix. In Unix you should use `$APP_NAME` instead of `%APP_NAME%`.

0

Hi. I'm trying this under windows and passing a path to a Powershell script (set to run as "source code"). I tried a lot of variations to get the path into the script, but everything I tried gave me a path of "null".

It looks like I should define an environment variable (which I did, called "fileURI"), then access it in the source code script as "%fileURI%" - but that doesn't work (null path):

$contents = get-content $file -Raw
[16:08:20][Step 3/7] + ~~~~~
[16:08:20][Step 3/7] + CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException
[16:08:20][Step 3/7] + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetContentC
[16:08:20][Step 3/7] ommand
0

Please sign in to leave a comment.