This page last changed on Nov 30, 2010 by ccnet-doc-gen.

Executable Task

The Executable Task lets you invoke any command line executable. It doesn't offer as much specific integration as (for example) the NAnt Task, but does allow you to hook almost anything up as a build process to CCNet. CCNet will examine the exit code when the executable ends and act accordingly.

Version

Available from version 1.0

Examples

Minimalist example
<exec executable="c:\projects\myproject\build.bat" />
Full 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>

Configuration Elements

Element Description Type Required Default Version
buildArgs Any command line arguments to pass in. String No None 1.0
buildTimeoutSeconds Number of seconds to wait before assuming that the process has hung and should be killed. If the build process takes longer than this period, it will be killed. Specify this value as zero to disable process timeouts. Int32 No 600 1.0
baseDirectory The directory to run the process in. If relative, is a subdirectory of the Project Working Directory. String No Project working directory 1.0
description Description used for the visualisation of the buildstage, if left empty the process name will be shown. String No The task/publisher name. 1.5
dynamicValues The dynamic values to use for the task. Dynamic Values array No None 1.5
environment A set of environment variables set for commands that are executed.
Each variable should be specified as
<variable name="name" value="value" />

.
Environment Variable array No    
executable The path of the program to run. If this is relative, then must be relative to either (a) the base directory, (b) the CCNet Server application, or (c) if the path doesn't contain any directory details then can be available in the system or application's 'path' environment variable. String Yes n/a 1.0
priority The priority class of the spawned process. String - one of:
  • Normal
  • Idle
  • High
  • RealTime
  • BelowNormal
  • AboveNormal
No Normal 1.5
successExitCodes The list of exit codes that indicate success, separated by commas. String No None 1.0

Notes

An exit code of -1 is always treated as the operation has timed out. This will fail the build.

Windows seems to change the case of environment variables occasionally. If your task target doesn't find one of these properties, try using all upper case or all lower case versions of these properties.

Frequently Asked Questions

Does the exec task pass the integration properties via the command line?
No. The integration properties are only available as environment variables. As there is no way of knowing the way in which the external program expects these properties to be formatted as command line arguments, environment variables are a simple, common medium for making these values accessible. To pass these environment variables into an external program, have the exec task call a batch file instead that will pick up the environment variables, format them and pass them as command line arguments to the external program.
Using built in shell commands
In Windows use cmd.exe as the executable, and pass the wanted command as an argument, preceded with /c. This allows to execute del *.* and the like. For example :

<exec>
  <executable>c:\Windows\System32\cmd.exe</executable>
  <buildArgs>/C NET STOP "Service name"</buildArgs>
</exec>

The following parameters are passed to the external program using environment variables, in addition to those you specify in the <environment> element.:

Label Description Example Version
CCNetBuildCondition The condition used to trigger the build, indicating if the build was triggered by new modifications or if it was forced. Legal values are: "IfModificationExists" or "ForceBuild" ForceBuild  
CCNetIntegrationStatus The status of the current integration. Could be Success, Failure, Exception or Unknown Success  
CCNetLabel The label used to identify the CCNet build. This label is generated by the CCNet labeller. 1.0.2.120  
CCNetLastIntegrationStatus The status of the previous integration. Could be Success, Failure, Exception or Unknown Success  
CCNetProject The name of the CCNet project that is being integrated. MyProject  
CCNetBuildDate The date of the build (in yyyy-MM-dd format) 2005-08-10  
CCNetBuildTime The time of the start of the build (in HH:mm:ss format) 08:45:12  
CCNetArtifactDirectory The project artifact directory (as an absolute path) c:\program files\CruiseControl.NET\Server\MyProject\Artifacts  
CCNetWorkingDirectory The project working directory (as an absolute path) c:\program files\CruiseControl.NET\Server\MyProject\WorkingDirectory  
CCNetRequestSource The source of the integration request; this will generally be the name of the trigger that raised the request. IntervalTrigger 1.1.0
CCNetFailureUsers The list of users who have contributed modifications to a sequence of builds that has failed. John, Smith
 
CCNetListenerFile Viewing build progress with Nant and MSBuild c:\Project\Artifact\listener.xml 1.4.0
CCNetProjectUrl The URL where the project is located http://myhost/ccnet/server/  
CCNetNumericLabel Contains the label as an integer if conversion is possible, otherwise zero. 1  
CCNetModifyingUsers
The list of users who have contributed to the current build only
Smith  
CCNetUser The user who forced the build. If security is off, or the build is not forced, then this will not be set. John Doe 1.5.0
Automatically Generated

Documentation generated on Tuesday, 30 Nov 2010 at 10:25:51 AM
Using assembly version 1.6.7805.1

Document generated by Confluence on Jan 23, 2011 08:52