Python Example |
Top Previous Next |
This is an example IronPython script that can be tested outside of FinalBuilder Server using the Context.py stub (see Script Based Triggers).
import Context
#copy from here
from System import DateTime
def TriggerTest(): app = 'cmd.exe' wd = r'C:\Windows\System32'
if Context.ComparisonDateTime < DateTime.Now.AddMinutes(-30): result = Context.ExecuteProgram(app, wd, '/c "echo hi"') if result.ExitCode == 0: Context.SetTriggered() Context.AddTriggerOutputMessage('%s successful, build will be triggered' % app) else: print 'Build will not be triggered' print '%s failed with return codee %d: %s ' % (app, result.ExitCode, result.StdError) else: print 'Build has been run in the last 30 minutes - not running'
TriggerTest()
#copy to here
print Context.Output()
Things to note:
|