Dashboard > CruiseControl.NET > ... > Task Blocks > Executable Task
Executable Task Log In | Sign Up   View a printable version of the current page.  
CruiseControl.NET documentation for latest CI builds
Added by Mike Roberts , last edited by Craig Sutherland on Jun 25, 2009  (view change)

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.

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:

Node Description Type Required Default Version
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 true n/a  
baseDirectory The directory to run the process in. If relative, is a subdirectory of the Project Working Directory string false Project Working Directory  
buildArgs Any command line arguments to pass in string false no arguments  
buildTimeoutSeconds Number of seconds to wait before assuming that the process has hung and should be killed. int false 600 (10 minutes)  
successExitCodes A comma-separated list of exit codes that indicate success. list of ints false 0  
environment Specifies any environment variables to set for the executable. complex false
(none)  
description If filled in, this will be shown in the buildstage as the process name
string
false
n/a  
dynamicValues Any dynamic parameters to be used. See Dynamic Parameters Dynamic values array - see Dynamic Parameters No None 1.5.0

Integration Properties

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
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.

Exit codes

Code Description CCNet Behavior
a code in <successExitCodes> Success The build continues
-1 Timed out The operation timed out and the build fails
other Failure The build fails

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.
see also Command help

example :

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


Powered by a free Atlassian Confluence Open Source Project License granted to ThoughtWorks, Inc.. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators