Conditional Commands

Top  Previous  Next

 

Conditional Commands allow you to elect to run a Command that will do the actual work you need done in the pipeline ONLY if a Condition is run successfully and evaluates to True.  Effectively this utilises three commands in one:

 

1.The If Command that tells the Pipeline Runner to create a special type of command which executes only if a specified Condition is met

2.The Condition, also known as a Validation Command, will determine if any action is taken when the command is processed

3.The Executable Command or Command Group that will actually do the work if the validation command succeeds

4.Optionally, an Alternative Executable Command or Command Group that will do the work if the validation command fails

 

Each part has a very simple syntax that does not really require much in the way of knowledge to use them.

 

Command Syntax

 

The Command syntax is really simple.  You put the If command name, followed by a colon, then the Validation command with any required parameters, then a comma, and then the Executable command again along with any required parameters. Optionally you can add an Alternative Executable command again along with any required parameters to perform an action if the validation command fails.

 

In addition you can use the Begin and End commands to create Command Groups. This will allow you to execute multiple commands in the Executable and AlternativeExecutable sections of the command.

 

Example

 

Here is a simple example for a conditional Copy File command which attempts to copy the file ONLY if the FileExists condition confirms that the file actually exists:

 

If:FileExists:"c:\Test Text.txt",CopyFile:"C:\Test Text.txt","C:\Test Text (copy).txt"

 

See Also: Commands Conditions If Command Command Groups Begin End