CruiseControl Fail - cruisecontrol.net

I have a batch file that is running inside CruiseControl and outputing either "Pass" or "Fail". How can I manage CruiseContorl so that the build fails if the output of my batch file is "Fail"?

If the return value of the batch file is non-zero, the build will report as having failed.

in your ant script use the failonerror flag:
<exec executable="xxx" failonerror="true">
The executable (script) needs to signal failure by setting an non zero return code (call to exit)

Related

How to define a new command line program?

I'm trying to define a command line program which will automatically call a specified Nodejs application.
I want to define it like that:
mycommand newFile
And that will call this application:
node E:/nodejsApp/mycommand.js newFile
mycommand.js is ready now. I want to call it with directly mycommand command on cmd in Windows 10.
For that, create a batch file in your path (ex: C:\WINDOWS\System32) with that code:
node E:\nodejsApp\mycommand.js %1
Save it as the command you want to create + the batch extension ([command].bat)
Another option will be, as aschipfl mentioned, use the doskey command creating an autorun. Note that I recommend creating the batch file, as running a command at starting of CMD will slow down his starting.
For the AutoRun, create a registry key at HKCU\Software\Microsoft\Command Processor called AutoRun, type REG_MULTI_SZ and write the value of doskey mycommand=node E:\nodejsApp\mycommand.js %1

Using Gradle, how can I ensure that a command exists

I am using Gradle for AOSP, I would like to check if a command exists in my build environment.
task printCommand{
doLast{
def command = "git --version"
println command.execute().text
}
}
Above code run perfect, it will print the output from command "git --version".
But I try another command according to Check if a program exists from a Bash script
task printCommand{
doLast{
def command = "command -v docker"
println command.execute().text
}
}
It always show the wrong message like this.
Execution failed for task ':printCommand'.
java.io.IOException: Cannot run program "command": error=2, No such file or directory
Why I can't use "command -v docker" in this way ?
Are there any better ways to check if a command exists in Gradle ?
command is a builtin bash command, not a binary.
groovy's String.execute will start a process. The binary that the process is started from has to be given fully qualified (e.g. "/usr/bin/docker --version") or must be found on your $PATH (or %PATH%)
Get back to the subject, I find the way to ensure that a command exists while using Gradle, this code can avoid Gradle script terminated by non-zero exitValue, and print the appropriate information.
task checkCommand{
doLast{
result = exec{
def command = "command -v docker"
ignoreExitValue = true
executable "bash" args "-l", "-c", command
}
if(result.getExitValue()==0){
println "Has Docker"
}else{
print "No Docker"
}
}
}
Update 2019/02/23
If you get this error:
Could not set unknown property 'result' for task ':checkCommand' of
type org.gradle.api.DefaultTask
Add def in front of result will fix this issue.

Can a TeamCity Linux build agent run Perl tests with TAP output?

I've been able to add a Linux machine as build agent in TeamCity without too much hassle, but it's having some trouble running my Perl test suite. When I add this as a build step:
prove -j4 --formatter TAP::Formatter::TeamCity
I get the following error :
Missing '...' at end of YAMLish at /usr/local/lib/perl5/site_perl/5.18.0/TAP/Parser /YAMLish/Reader.pm line 49, line 2.
Process exited with code 25
Step Run test scripts (Command Line) failed
I actually get that whether I pass a --formatter value or not. When I run this from the local command line of the same machine, it runs just fine. That area in Reader.pm looks like this:
# The terminator is mandatory otherwise we'd consume a line from the
# iterator that doesn't belong to us. If we want to remove this
# restriction we'll have to implement look-ahead in the iterators.
# Which might not be a bad idea.
my $dots = $self->_peek;
die "Missing '...' at end of YAMLish" #Line 49
unless defined $dots
and $dots =~ $IS_END_YAML;
I tried changing that die to a warn and sure enough it started ingesting all the console output and it of course choked before too long.
uname -r on the Linux box yields 3.5.0-45-generic #68-precise1-Ubuntu.
Anyone know any ways around this?

Post build event in VS2012..Running a Batch file

Am trying to run a Batch file in Post build event in Visual studio.
Referred Can we execute a .bat file in post build event command line in visual studio? for reference.
When i post the line
xcopy "$(ProjectDir)bin" "$(SolutionDir)Deploy\bin" /S in postbuild
am getting the expected result
Same line i put in bat and tried calling
call "$(SolutionDir)\Deploy.bat"
or
call "Physical path\deploy.bat"
Am getting excited with code 1. What am i doing wrong here ?
Can i specify macros inside batch file ?
Thanks
You are getting a VS error because it returned an exit code that is not 0. This does not necessarily mean there was an error.
The error code returned means that no files were copied.
These are the return codes for Xcopy:
Exit Code
0 Files were copied without error.
1 No files were found to copy.
2 The user pressed Ctrl+C to terminate xcopy.
4 Various errors including insufficient memory or disk space, an invalid drive name, or invalid syntax.
5 Disk write error occurred.
Try this code in your batch file. Use the /Y so that you will not have to deal with any prompts. You can handle the return code of 1 with another action or just return 0.
VS Post Build command line code:
CALL "$(SolutionDir)"Deploy.bat "$(ProjectDir)bin" "$(SolutionDir)Deploy\bin"
Deploy.bat file
Xcopy %1 %2 /S /Y
If errorlevel 1 #exit 0

cruisecontrol.net exec task

I am using the <'exec> task inside cruisecontrol.net. I am executing a .bat file and passing the arguments using <'buildArgs>. I need to pass in more than one arguments and I'm not sure what the correct syntax is. I am trying to do something like <'buildArgs>Arg1 Arg2<'/buildArgs> but it doesn't work.
Try this:
<exec>
<executable>YourBatFile.cmd</executable>
<buildArgs>Arg1 Arg2</buildArgs>
</exec>
Then read the values in your bat file using %1 and %2

Resources