Skip to content

run schedules


For class object stacks, explicit job schedules are required. This is an uncommon requirement, but required for stacks with many jobs like CI or pipelines divided into grouping of jobs.

e.g. Example of a schedule for Docker CI.

def schedule(self):

    sched = self.stack.new_sched()
    sched.job = "record_commit"
    sched.archive.timeout = 300
    sched.archive.timewait = 60
    sched.archive.cleanup.instance = "clear"
    sched.failure.keep_resources = True
    sched.conditions.retries = 1
    sched.conditions.frequency = "wait_last_run 20"
    sched.automation_phase = "continuous_delivery"
    sched.human_description = "Insert commit info into run"
    sched.on_success = [ "unit_test" ]
    self.stack.add_sched(sched)

    sched = self.stack.new_schedule()
    sched.job = "unit_test"
    sched.archive.timeout = 2700
    sched.archive.timewait = 120
    sched.archive.cleanup.instance = "clear"
    sched.failure.keep_resources = True
    sched.conditions.frequency = "wait_last_run 60"

    # Cannot have concurrency with a single docker host
    # The belows says another unit_test cannot run
    # while register_docker is running b/c they run on the
    # same dockerhost.  This can change with a more sophisicated
    # stack.  This will also prevent a bunch of builds from completing
    # b/c of a race conditions.  It's not a big deal because
    # the "runs" don't complete as it waits to stop the server, but
    # the unit_test and register of docker has completed.

    sched.conditions.noncurrent = [ "register_docker", "stop_server" ]
    sched.automation_phase = "continuous_delivery"
    sched.human_description = "Running unit_test for code"
    sched.on_success = [ "register_docker" ]
    sched.on_failure = [ "stop_server" ]
    self.stack.add_sched(sched)

    sched = self.stack.new_sched()
    sched.job = "register_docker"
    sched.archive.timeout = 2700
    sched.archive.timewait = 120
    sched.archive.cleanup.instance = "clear"
    sched.failure.keep_resources = True
    sched.conditions.noncurrent = [ "unit_test", "stop_server" ]
    sched.conditions.frequency = "wait_last_run 60"
    sched.automation_phase = "continuous_delivery"
    sched.human_description = "Building docker container with code"
    sched.on_success = [ "stop_server" ]
    sched.on_failure = [ "stop_server" ]
    self.stack.add_sched(sched)

    sched = self.stack.new_sched()
    sched.job = "stop_server"
    sched.archive.timeout = 300
    sched.archive.timewait = 10
    sched.archive.cleanup.instance = "clear"
    sched.failure.keep_resources = True
    sched.conditions.noncurrent = [ "unit_test", "register_docker" ]
    sched.conditions.frequency = "wait_last_run 10"
    sched.automation_phase = "continuous_delivery"
    sched.human_description = "Stopping docker host"
    self.stack.add_sched(sched)

    return self.stack.schedules
self.stack.new_sched - creates a job schedule object.

self.stack.add_sched(sched) - finalizes a schedule job object, where “sched” is the object.

e.g. new_sched to add_sched

sched = self.stack.new_sched()
...
...
...
self.stack.add_sched(sched)<br>