Set Conrinua Variable by external script

Hi
I know I can setup Continua Variable from FinalBuilder there is such action in FB 7. 
Is there way to do it from power shell script or other external way?
Thanks

Hi Sergey,

You can set Continua CI variables from PowerShell scripts, batch files or other external programs by writing custom log messages to the console. e.g. 

$message = "Continua CI is awesome!"
write-Host “@@continua[setVariable name=‘messageFromScript’ value=’$message’]”

Hello,

I am struggling with setting up a variable in this way (sort of). I want to just run a PowerShell command in my stage without creating script files. I have other commands that succeed if I simply invoke them in a Run DOS command action, like such:

PowerShell -command (get-item MyAssembly.dll).versioninfo.fileversion

So I’m trying to set a variable in the same way:

PowerShell -command {write-Host “@@continua[setVariable name=‘PlatformVersion’ value=‘1.2’]”}
PowerShell -command (write-Host “@@continua[setVariable name=‘PlatformVersion’ value=‘1.2’]”)
PowerShell -command write-Host “@@continua[setVariable name=‘PlatformVersion’ value=‘1.2’]”

I’ve tried all of the above but they all return the same errors:

At line:1 char:13
+ (write-Host @@continua[setVariable name=‘PlatformVersion’ value=‘1.2’])
+ ~
Unrecognized token in source text.
At line:1 char:24
+ (write-Host @@continua[setVariable name=‘PlatformVersion’ value=‘1.2’])
+ ~
Array index expression is missing or not valid.
At line:1 char:14
+ (write-Host @@continua[setVariable name=‘PlatformVersion’ value=‘1.2’])
+ ~~~~~~~~~
The splatting operator ‘@’ cannot be used to reference variables in an
expression. ‘@continua’ can be used only as an argument to a command. To
reference variables in an expression use ‘$continua’.
+ CategoryInfo : ParserError: ( I know that I’m probably making a simple mistake, but I will need your help to figure it out. Thank you.

Hi Lesergeur,

You can use the “& {}” syntax as follows 

PowerShell -command "& {write-Host “@@continua[setVariable name=‘PlatformVersion’ value=‘1.2’]”}"

Note the use of backslashes to escape double quotes.

You don’t however need to use PowerShell at all here - as you are using a DOS Command action you can simply use the DOS command “echo” to write out the custom log message.

echo @@continua[setVariable name=‘PlatformVersion’ value=‘1.2’]

Furthermore, Continua CI has a Set Variable action - why not just use this? 







Hello Dave,

My actual intention is to set a variable to a value that I can best obtain from a PowerShell command. My example above was only to help me resolve a basic PowerShell error. (I did have a hunch from the error that something was amiss with the quote, but did not realize it needed to be escaped.)

My final command turns out to be this: <

PowerShell -command "& {write-Host \"@@continua[setVariable name='PlatformVersion' value='$((get-item MyAssembly.dll).versioninfo.productversion)']\"}"

It works. Thank you for your help!

Let me try that again…

PowerShell -command "& {write-Host \"@@continua[setVariable name='PlatformVersion' value='$((get-item MyAssembly.dll).versioninfo.productversion)']\"}"