Script Based Triggers

Top  Previous  Next

Script Based Triggers allow you to use a Python or PowerShell script to determine if a build will be triggered.

 

ScriptBasedTriggerOptions

Language

The language you wish to use for the script. Currently Python and PowerShell are supported.

 

Iron Python Install Directory

Optional: the directory where Iron Python is installed. Specifying this location allows you to import any of the modules shipped with IronPython.

 

Script

The script to execute. In order for a build to be triggered, either Context.SetTriggered() or $context.SetTriggered() must be called. See below.

 

The Context object

An object is made available to both languages that allows you to interact with the build server. In Python, it is exposed as a module called Context, which you do not need to import. In PowerShell, it is exposed as a variable called $context.

 

Context methods

SetTriggered(): This is the most important method of the Context object. Calling this method means that the build will be queued
AddTriggerOutputMessage(message): The string parameter passed to this method is logged in the build queue. Use this to provide information about the circumstances triggered the build
AddFileModificationItem(name, action, user, comment, type, version ): Adds information about a file that was involved in the build triggering. This is logged and also passed to FinalBuilder, for use in the Trigger Files Iterator action
ExecuteProgram(filename, workingDirectory, arguments): This method runs an executable under the context of user set to run the build. It returns an ExecutionResult object
ComparisonDateTime: a DateTime property used to indicate when the trigger was last triggered, or when the last build started (which ever is more recent). It is useful when, for example, you are checking against a version control system and only want to find changes since the last build.

 

Context.py stub

A stub IronPython module has been provided to allow you to test scripts without needing to run them on the build server. This can be found in the <FinalBuilder Server Install Dir>\Examples.

 

Example.py

A simple IronPython script demonstrating how to use the Context module. This can be found in the <FinalBuilder Server Install Dir>\Examples.