Execute a command-line command from CruiseControl.NET

孤街醉人 提交于 2019-12-22 07:01:33

问题


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>

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.

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.

What am I doing wrong?

EDIT:

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

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

The batch file contents:

SETX SELENIUM_BROWSER googlechrome /M

回答1:


Formatting the command like this sets the environment variable correctly:

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

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

UPDATE:

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.



来源:https://stackoverflow.com/questions/5233389/execute-a-command-line-command-from-cruisecontrol-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!