【问题标题】:Powershell Task from CC.net来自 CC.net 的 Powershell 任务
【发布时间】:2014-01-30 17:48:04
【问题描述】:

如何将构建参数和环境变量从 cc.net 传递给 powershell 脚本

我在这里看到文档:http://build.nauck-it.de/doc/CCNET/PowerShell%20Task.html

如果我有类似的函数,我不清楚语法应该是什么

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

我能做到以下几点:

<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>

【问题讨论】:

    标签: powershell cruisecontrol.net build


    【解决方案1】:

    看起来您必须创建一个脚本来包装对您的函数的调用。换句话说,在C:\Scripts 目录中创建一个文件“dosomething.ps”,看起来像

    Concat $env:someEnviromentVariable1 $env:someEnviromentVariable2 $args
    

    请注意,这假定 Concat 函数在运行时位于脚本范围内。您可以通过将其包含在您的 powershell profile 中来做到这一点,或者通过“在脚本本身中点源它:

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

    【讨论】:

    • 让我们暂时忘记调用该函数。我将满足于传递构建参数和环境变量的正确方法。
    • @bearrito:CC.Net 不为你做吗?
    • 不,我不知道如何将环境变量作为环境变量或构建参数传递。我可以传入严格的构建参数,但不能传入环境变量。
    • 你是对的。 CC.NET 将所有 CC Env 变量加载到 powershell 会话中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-06
    • 2020-03-29
    • 1970-01-01
    • 2021-09-23
    • 2011-06-22
    • 1970-01-01
    • 2010-09-25
    相关资源
    最近更新 更多