从CruiseControl.NET执行命令行命令 [英] Execute a command-line command from CruiseControl.NET

查看:52
本文介绍了从CruiseControl.NET执行命令行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 CruiseControl.NET 配置中有以下代码块:

I have this block of code in the CruiseControl.NET configuration:

<exec>
    <executable>C:\Windows\System32\cmd.exe</executable>
    <buildArgs>/C SETX SELENIUM_BROWSER googlechrome /M</buildArgs>
</exec>

其后是 NUnit 执行命令,该命令将运行某些 Selenium 在我的网站上进行测试。这个想法是在运行测试之前,该命令会更改测试浏览器(系统环境变量)。

It is followed by an NUnit execution command that will run some Selenium tests on my website. The idea is that this command changes the testing browser (system environment variable) before the tests are run.

问题是该命令似乎不起作用。测试仍在使用默认浏览器Firefox。

The problem is that the command does not seem to be working. The tests are still using the default browser, Firefox. It works if I manually change the environment variable.

我在做什么错了?

编辑:

我尝试将命令放入批处理文件中并执行该命令,但仍然无法正常工作:

I tried putting the command in a batch file and executing that, but it still didn't work:

<exec executable="C:\CCNet\setChrome.bat" />

批处理文件内容:

SETX SELENIUM_BROWSER googlechrome /M


推荐答案

这样格式化命令可以正确设置环境变量:

Formatting the command like this sets the environment variable correctly:

<exec>
    <executable>cmd</executable>
    <buildArgs>/C SETX SELENIUM_BROWSER googlechrome /M</buildArgs>
</exec>

现在,我需要弄清楚为什么我的NUnit测试不能正确地将其拾取。

Now I need to figure out why my NUnit tests aren't correctly picking it up.

更新:

应该在环境中使用环境元素可执行任务,将变量传递给测试。例如:

Should have used the environment element in the executable task to pass variables to the test. For example:

<exec>
    <executable>make</executable>
    <baseDirectory>D:\dev\MyProject</baseDirectory>
    <buildArgs>all</buildArgs>
    <buildTimeoutSeconds>10</buildTimeoutSeconds>
    <successExitCodes>0,1,3,5</successExitCodes>
    <environment>
        <variable>
            <name>MyVar1</name>
            <value>Var1Value</value>
        </variable>
        <variable name="MyVar2" value="Var2Value" />
    </environment>
</exec>

我实际上是在一个小的配置文本文件中实现了浏览器设置,但这是一个解决方法变得更容易,并且我不需要运行任何命令行命令。

I actually implemented the browser setting in a little config text file as a workaround, but this element would have made it easier and I wouldn't have needed to run any command line commands.

这篇关于从CruiseControl.NET执行命令行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆