开发者

Powershell Task from CC.net

开发者 https://www.devze.com 2023-02-16 00:05 出处:网络
How do I pass in build args and environment variables to a powershell script from cc.net I see the docs here : http://build.nauck-it.de/doc/CCNET/PowerShell%20Task.html

How do I pass in build args and environment variables to a powershell script from cc.net

I see the docs here : http://build.nauck-it.de/doc/CCNET/PowerShell%20Task.html

It is not clear exactly what the syntax should be if I have a function like

Function Concat([String] someEnviromentVariable1,[String] someEnviromentVariable2 ,[String] abuildArg1, [String] abuildArg2 )
{
 ///stuff happens
}

Could I do the following:

<开发者_如何学运维;powershell>
<script>dosomething.ps</script>
<executable>C:\program Files\PowerShell\PowerShell.exe</executable>
<scriptsDirectory>C:\Scripts</scriptsDirectory>
<buildArgs>-abuildArg1=2 -abuildArg2=3</buildArgs>
<environment>
<variable name=" someEnviromentVariable1"/>
<variable name=" someEnviromentVariable2"/>
</environment>
<successExitCodes>1,2,3</successExitCodes>
<buildTimeoutSeconds>10</buildTimeoutSeconds>
<description>Example of how to run a PowerShell script.</description>
</powershell>


It looks like you'll have to create a script that wraps the call to your function. In other words, create a file "dosomething.ps" in the C:\Scripts directory that looks like

Concat $env:someEnviromentVariable1 $env:someEnviromentVariable2 $args

Note that this assumes that the Concat function is in the scope of the script when it is run. You could do this by including it in your powershell profile, or by "dot sourcing it in the script itself:

. .\scriptThatContainsConcatDefinition.ps1
Concat $env:someEnviromentVariable1 $env:someEnviromentVariable2 $args
0

精彩评论

暂无评论...
验证码 换一张
取 消