English 中文(简体)
How to ignore output from executable with CruiseControl.Net build?
原标题:

I m running a little find and replace utility called fart.exe (yes, fart, as in Find and Replace Text) as part of my CC build. Works great.

The problem is that FART while it is working displays a little ASCII spinner composed of pipe, dash, slash... | / - . There isn t a way to suppress this spinner, and CC thinks these little symbols are error messages and the build fails. I ve tried:

  • adding those symbols as successexitcodes in CC -- same result, apparently only ints work
  • Calling fart via a batch file with ECHO OFF -- it still outputs the spinner and causes the build to fail

Any other ideas?

<exec>
<executable>C:fart.exe</executable>
<buildArgs>myfile.txt string1 string2</buildArgs>
<successExitCodes>1,0</successExitCodes>
</exec>
最佳回答

Thanks for the answers, but I ended up doing two things:

  • Recompiled the text replacement app (fart) without the spinner. Even after doing this CC was still failing for some reason, so I...
  • Moved batch executables to the msbuild file instead of cc config file. CC then built successfully.

I m sure if I understood CC better I could have gone about this better way but for now this does the trick!

问题回答

I also ran into this issue with fart and a ci system. Rather than recompile the executable, I redirected the output to NUL.

First I determined that the spinner output was on stderr. Then I appended "2>NUL" to the command line which called fart, and it no longer farted a spinner on stderr.

Anybody else getting a pinwheel in a smelly breeze visual from that last sentence?

In my case I needed to run fart.exe from a batch file which was run later on by Jenkins, and here is what I found out.

fart.exe returns in %errorlevel% the amount of replacements that are done. If that amount is 1, that will be the value of %errorlevel%, which means having an exit code 1, what will make Jenkins fail.

In order to fix this here is what I added to my batch file:

REM standard "fart.exe" error-handling block; 9009 (missing program) is bad, anything else above 0 is OK and should be reset to 0 for standard handling
if ERRORLEVEL 9009 (
    REM do nothing
) else (
    if ERRORLEVEL 1 CMD /C EXIT 0
)

REM ensure that we exit with the current errorlevel context...
exit %errorlevel%

Adding ECHO OFF to the call of fart.exe made the %errorlevel% value be 0 again, but by doing that the replacements done by fart stopped being successful.

I hope this helps someone!

I have run into the same issue. And, found out FART returns errorlevel =1 when it success and return errorlevel = 0 when it failed with "access denied" or "file not found" and etc. So, force errorlevel to 0 when it runs successfully and force it to 1 when it fails. It works for me.

The successExitCodes list is supposed to be a list of ints. Here s a couple of suggestions:

  1. Create a small batch file that runs the executable and call your batch file (instead of fart) using the executable task.
  2. Try removing the non ints from the successExitCodes and verify what exit code fart is returning... sometimes you get unexpected return codes, like when using robocopy.

For command line apps, you can redirect output to a file using the > character. A call to your app would look like:

fart.exe myfile.txt string1 string2 > myoutput.txt

Adding the redirect to your buildArgs property should do the trick.

This line seems to work using fart:

<exec program="fart.exe" commandline="${filename} 1.0 1.1" verbose="true" failonerror="false" />

However I am not sure if the failonerror can be handled otherwise





相关问题
Eclipse CDT static resources under build folder

I m building a C++ project under Eclipse and my release folder should include a static sub-folder with some files inside it, those are required by executable during runtime. The problem is that this ...

Multiple Output paths for a C# Project file

Can I use multiple output paths. like when i build my project, the exe should generate in two different paths. If so, How can I specify in Project Properties-> Build -> output path? I tried using , ...

Running multiple TeamCity Agents on the same computer?

We have several build machines, each running a single TeamCity build agent. Each machine is very strong, and we d like to run several build agents on the same machine. Is this possible, without using ...

couldnt recognise pom.xml file

i am build forge as build tool. it is executing maven mvn commands fine ,but it couldnt recognizing the maven project pom.xml to run the build.so i tried to execute the same pom.xml through the ...

Cobertura ant script is missing Log4J classes

I tried to get Cobertura running inside my ant script, but I m stuck right at the beginning. When I try to insert the cobertura taskdef I m missing the Log4J libraries. Ant properties & ...

Why not use TFS as a build / CI solution?

Currently our build solution is set up using TFS + MS Build scripts. TFS is also being used as a CI server. I ve seen several posts on this site telling people about other CI solutions. Are there ...

Multiple websites running on same codebase?

We are developing an application that would be offered as a hosted solution. I am struck with understanding how can i use multiple sites with same code without duplicating base code. eg: website 1: ...

热门标签